OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 | 1476 |
1477 void Genesis::BuildSpecialFunctionTable() { | 1477 void Genesis::BuildSpecialFunctionTable() { |
1478 HandleScope scope; | 1478 HandleScope scope; |
1479 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); | 1479 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); |
1480 // Add special versions for Array.prototype.pop and push. | 1480 // Add special versions for Array.prototype.pop and push. |
1481 Handle<JSFunction> function = | 1481 Handle<JSFunction> function = |
1482 Handle<JSFunction>( | 1482 Handle<JSFunction>( |
1483 JSFunction::cast(global->GetProperty(Heap::Array_symbol()))); | 1483 JSFunction::cast(global->GetProperty(Heap::Array_symbol()))); |
1484 Handle<JSObject> visible_prototype = | 1484 Handle<JSObject> visible_prototype = |
1485 Handle<JSObject>(JSObject::cast(function->prototype())); | 1485 Handle<JSObject>(JSObject::cast(function->prototype())); |
1486 // Remember to skip the hidden prototype: | 1486 // Remember to put push and pop on the hidden prototype if it's there. |
1487 Handle<JSObject> hidden_prototype = | 1487 Handle<JSObject> push_and_pop_prototype; |
1488 Handle<JSObject>(JSObject::cast(visible_prototype->GetPrototype())); | 1488 Handle<Object> superproto(visible_prototype->GetPrototype()); |
1489 AddSpecialFunction(hidden_prototype, "pop", | 1489 if (superproto->IsJSObject() && |
| 1490 JSObject::cast(*superproto)->map()->is_hidden_prototype()) { |
| 1491 push_and_pop_prototype = Handle<JSObject>::cast(superproto); |
| 1492 } else { |
| 1493 push_and_pop_prototype = visible_prototype; |
| 1494 } |
| 1495 AddSpecialFunction(push_and_pop_prototype, "pop", |
1490 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); | 1496 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); |
1491 AddSpecialFunction(hidden_prototype, "push", | 1497 AddSpecialFunction(push_and_pop_prototype, "push", |
1492 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); | 1498 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); |
1493 ASSERT(hidden_prototype->map()->is_hidden_prototype()); | |
1494 } | 1499 } |
1495 | 1500 |
1496 | 1501 |
1497 Genesis::Genesis(Handle<Object> global_object, | 1502 Genesis::Genesis(Handle<Object> global_object, |
1498 v8::Handle<v8::ObjectTemplate> global_template, | 1503 v8::Handle<v8::ObjectTemplate> global_template, |
1499 v8::ExtensionConfiguration* extensions) { | 1504 v8::ExtensionConfiguration* extensions) { |
1500 // Link this genesis object into the stacked genesis chain. This | 1505 // Link this genesis object into the stacked genesis chain. This |
1501 // must be done before any early exits because the destructor | 1506 // must be done before any early exits because the destructor |
1502 // will always do unlinking. | 1507 // will always do unlinking. |
1503 previous_ = current_; | 1508 previous_ = current_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 } | 1567 } |
1563 | 1568 |
1564 | 1569 |
1565 // Restore statics that are thread local. | 1570 // Restore statics that are thread local. |
1566 char* Genesis::RestoreState(char* from) { | 1571 char* Genesis::RestoreState(char* from) { |
1567 current_ = *reinterpret_cast<Genesis**>(from); | 1572 current_ = *reinterpret_cast<Genesis**>(from); |
1568 return from + sizeof(current_); | 1573 return from + sizeof(current_); |
1569 } | 1574 } |
1570 | 1575 |
1571 } } // namespace v8::internal | 1576 } } // namespace v8::internal |
OLD | NEW |