jitcraft/BytecodeCompiler.cpp
changeset 32 af1ed58252ac
parent 30 8c8bf75114f7
child 33 95baf120f7d4
     1.1 --- a/jitcraft/BytecodeCompiler.cpp	Tue Jul 03 00:28:21 2012 -0700
     1.2 +++ b/jitcraft/BytecodeCompiler.cpp	Tue Jul 03 00:32:19 2012 -0700
     1.3 @@ -530,7 +530,6 @@
     1.4  static inline ArrayMap *
     1.5  BuildArrayMap(Zone *zone, Handle<Type> type)
     1.6  {
     1.7 -    // :TODO: use local
     1.8      Local<ArrayMap> contained(zone);
     1.9      if (type->levels() > 1) {
    1.10          Local<Type> containedType(zone, type->contained());
    1.11 @@ -545,7 +544,6 @@
    1.12  void
    1.13  BytecodeCompiler::visit(StringLiteral *node)
    1.14  {
    1.15 -    // :TODO: remove this Local
    1.16      Local<Type> type(zone_, node->type());
    1.17      Local<ArrayMap> map(zone_, BuildArrayMap(zone_, type));
    1.18      if (!map)
    1.19 @@ -569,7 +567,6 @@
    1.20      
    1.21      Local<Type> type(zone_, var->type());
    1.22      if (type->isArray()) {
    1.23 -        // :TODO: use Local
    1.24          Local<ArrayMap> map(zone_, BuildArrayMap(zone_, type));
    1.25          __ newarray_lifo(map);
    1.26  
    1.27 @@ -594,14 +591,13 @@
    1.28  void
    1.29  BytecodeCompiler::visit(CallExpression *node)
    1.30  {
    1.31 -    // :TODO: use Local
    1.32 -    Type *funType = node->callee()->type();
    1.33 +    Local<Type> funType(zone_, node->callee()->type());
    1.34  
    1.35      for (size_t i = 0; i < node->arguments()->size(); i++) {
    1.36          Expression *arg = node->arguments()->at(i);
    1.37  
    1.38 -        Type *given = arg->type();
    1.39 -        Type *actual = Type::cast(funType->parameters()->at(i));
    1.40 +        Local<Type> given(zone_, arg->type());
    1.41 +        Local<Type> actual(zone_, Type::cast(funType->parameters()->at(i)));
    1.42          if (actual->isReference()) {
    1.43              if (given->isReference()) {
    1.44                  // The input type is already a reference, so we're just passing
    1.45 @@ -656,7 +652,7 @@
    1.46  BytecodeCompiler::visit(FunctionStatement *node)
    1.47  {
    1.48      BytecodeCompiler child(zone_, tree_, module_);
    1.49 -    Function *fun = child.compileFunction(module_, node);
    1.50 +    Local<Function> fun(zone_, child.compileFunction(module_, node));
    1.51      if (!fun)
    1.52          return;
    1.53      
    1.54 @@ -676,7 +672,6 @@
    1.55      // Note: No need to record a life slot here, since it's part of the Frame.
    1.56      AutoEnterScope functionScope(this, node->scope());
    1.57  
    1.58 -    // :TODO: use locals
    1.59      locals_ = FixedArray::New(zone_, node->scope()->maxContainedLocals(), Heap::Tenure_Old);
    1.60  
    1.61      node->body()->accept(this);
    1.62 @@ -686,13 +681,13 @@
    1.63      if (__ oom())
    1.64          return NULL;
    1.65  
    1.66 -    ByteArray *bytes = ByteArray::New(zone_, __ length() * sizeof(bytecode), Heap::Tenure_Old);
    1.67 +    Local<ByteArray> bytes(zone_, ByteArray::New(zone_, __ length() * sizeof(bytecode), Heap::Tenure_Old));
    1.68      if (!bytes)
    1.69          return NULL;
    1.70      memcpy(bytes->raw(), __ buffer(), __ length());
    1.71  
    1.72      unsigned nargs = node->scope()->numArguments();
    1.73 -    FixedArray *args = FixedArray::New(zone_, nargs, Heap::Tenure_Old);
    1.74 +    Local<FixedArray> args(zone_, FixedArray::New(zone_, nargs, Heap::Tenure_Old));
    1.75      if (!args)
    1.76          return NULL;
    1.77  
    1.78 @@ -702,18 +697,18 @@
    1.79      for (size_t i = 0; i < node->scope()->maxContainedLocals(); i++)
    1.80          assert(locals_->at(i));
    1.81  
    1.82 -    FixedArray *objects = FixedArray::New(zone_, __ objects()->size(), Heap::Tenure_Old);
    1.83 +    Local<FixedArray> objects(zone_, FixedArray::New(zone_, __ objects()->size(), Heap::Tenure_Old));
    1.84      if (!objects)
    1.85          return NULL;
    1.86  
    1.87      for (size_t i = 0; i < __ objects()->size(); i++)
    1.88          objects->set(zone_, i, __ objects()->at(i));
    1.89  
    1.90 -    Code *code = Code::New(zone_, bytes, locals_, objects, __ maxStackDepth(), module_);
    1.91 +    Local<Code> code(zone_, Code::New(zone_, bytes, locals_, objects, __ maxStackDepth(), module_));
    1.92      if (!code)
    1.93          return NULL;
    1.94  
    1.95 -    Function *fun = Function::New(zone_, module_, code, node->fun()->type(), node->pos());
    1.96 +    Local<Function> fun(zone_, Function::New(zone_, module_, code, node->fun()->type(), node->pos()));
    1.97      if (!fun)
    1.98          return NULL;
    1.99      
   1.100 @@ -723,7 +718,6 @@
   1.101  Module *
   1.102  BytecodeCompiler::compile()
   1.103  {
   1.104 -    // :TODO: root
   1.105      module_ = Module::New(zone_, tree_->scope()->numFunctions());
   1.106      if (!module_)
   1.107          return NULL;