The ARM assembler tests don't install the standard JS natives. When
authorerik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 7 May 2009 00:10:01 +0000 (00:10 +0000)
committererik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 7 May 2009 00:10:01 +0000 (00:10 +0000)
setting up push and pop we shouldn't make too many assumptions about
the structure of classes like 'Array'.
Review URL: http://codereview.chromium.org/113068

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

src/bootstrapper.cc

index aa25afd4643f4969e2052e3e0db92fdb8c1c5ed3..09cf68dea26c32cf6530698d9efe95de08108aa5 100644 (file)
@@ -1483,14 +1483,19 @@ void Genesis::BuildSpecialFunctionTable() {
           JSFunction::cast(global->GetProperty(Heap::Array_symbol())));
   Handle<JSObject> visible_prototype =
       Handle<JSObject>(JSObject::cast(function->prototype()));
-  // Remember to skip the hidden prototype:
-  Handle<JSObject> hidden_prototype =
-      Handle<JSObject>(JSObject::cast(visible_prototype->GetPrototype()));
-  AddSpecialFunction(hidden_prototype, "pop",
+  // Remember to put push and pop on the hidden prototype if it's there.
+  Handle<JSObject> push_and_pop_prototype;
+  Handle<Object> superproto(visible_prototype->GetPrototype());
+  if (superproto->IsJSObject() &&
+      JSObject::cast(*superproto)->map()->is_hidden_prototype()) {
+    push_and_pop_prototype = Handle<JSObject>::cast(superproto);
+  } else {
+    push_and_pop_prototype = visible_prototype;
+  }
+  AddSpecialFunction(push_and_pop_prototype, "pop",
                      Handle<Code>(Builtins::builtin(Builtins::ArrayPop)));
-  AddSpecialFunction(hidden_prototype, "push",
+  AddSpecialFunction(push_and_pop_prototype, "push",
                      Handle<Code>(Builtins::builtin(Builtins::ArrayPush)));
-  ASSERT(hidden_prototype->map()->is_hidden_prototype());
 }