The number of heap slots stored in a scope includes the
authorkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 21 Dec 2009 10:24:11 +0000 (10:24 +0000)
committerkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 21 Dec 2009 10:24:11 +0000 (10:24 +0000)
fixed contexts slots. Take this into account when using
the new, fast context creation path to avoid allocating
too many slots (wasteful).
Review URL: http://codereview.chromium.org/501148

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3505 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/contexts.cc
src/execution.cc
src/ia32/codegen-ia32.cc
src/ia32/macro-assembler-ia32.cc

index ead73ee..19920d2 100644 (file)
@@ -52,11 +52,14 @@ Context* Context::global_context() {
   if (global()->IsGlobalObject()) {
     return global()->global_context();
   }
+
   // During bootstrapping, the global object might not be set and we
   // have to search the context chain to find the global context.
+  ASSERT(Bootstrapper::IsActive());
   Context* current = this;
   while (!current->IsGlobalContext()) {
-    current = Context::cast(JSFunction::cast(current->closure())->context());
+    JSFunction* closure = JSFunction::cast(current->closure());
+    current = Context::cast(closure->context());
   }
   return current;
 }
index 8a50864..0f935ac 100644 (file)
@@ -79,6 +79,10 @@ static Handle<Object> Invoke(bool construct,
     receiver = Handle<JSObject>(global->global_receiver());
   }
 
+  // Make sure that the global object of the context we're about to
+  // make the current one is indeed a global object.
+  ASSERT(func->context()->global()->IsGlobalObject());
+
   {
     // Save and restore context around invocation and block the
     // allocation of handles without explicit handle scopes.
index 1c5ecf0..8343690 100644 (file)
@@ -174,7 +174,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) {
     function_return_is_shadowed_ = false;
 
     // Allocate the local context if needed.
-    int heap_slots = scope_->num_heap_slots();
+    int heap_slots = scope_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
     if (heap_slots > 0) {
       Comment cmnt(masm_, "[ allocate local context");
       // Allocate local context.
index fb34925..3ecbcee 100644 (file)
@@ -1369,7 +1369,6 @@ Handle<Code> MacroAssembler::ResolveBuiltin(Builtins::JavaScript id,
       JSBuiltinsObject::kJSBuiltinsOffset + (id * kPointerSize);
   mov(edi, FieldOperand(edx, builtins_offset));
 
-
   return Builtins::GetCode(id, resolved);
 }