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 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 } | 1466 } |
1467 | 1467 |
1468 | 1468 |
1469 void Genesis::BuildSpecialFunctionTable() { | 1469 void Genesis::BuildSpecialFunctionTable() { |
1470 HandleScope scope; | 1470 HandleScope scope; |
1471 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); | 1471 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); |
1472 // Add special versions for Array.prototype.pop and push. | 1472 // Add special versions for Array.prototype.pop and push. |
1473 Handle<JSFunction> function = | 1473 Handle<JSFunction> function = |
1474 Handle<JSFunction>( | 1474 Handle<JSFunction>( |
1475 JSFunction::cast(global->GetProperty(Heap::Array_symbol()))); | 1475 JSFunction::cast(global->GetProperty(Heap::Array_symbol()))); |
1476 Handle<JSObject> prototype = | 1476 Handle<JSObject> hidden_prototype = |
1477 Handle<JSObject>(JSObject::cast(function->prototype())); | 1477 Handle<JSObject>(JSObject::cast(function->prototype())); |
1478 AddSpecialFunction(prototype, "pop", | 1478 ASSERT(hidden_prototype->map()->is_hidden_prototype()); |
| 1479 // Remember to skip the hidden prototype: |
| 1480 Handle<JSObject> real_prototype = |
| 1481 Handle<JSObject>(JSObject::cast(hidden_prototype->GetPrototype())); |
| 1482 AddSpecialFunction(real_prototype, "pop", |
1479 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); | 1483 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); |
1480 AddSpecialFunction(prototype, "push", | 1484 AddSpecialFunction(real_prototype, "push", |
1481 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); | 1485 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); |
1482 } | 1486 } |
1483 | 1487 |
1484 | 1488 |
1485 Genesis::Genesis(Handle<Object> global_object, | 1489 Genesis::Genesis(Handle<Object> global_object, |
1486 v8::Handle<v8::ObjectTemplate> global_template, | 1490 v8::Handle<v8::ObjectTemplate> global_template, |
1487 v8::ExtensionConfiguration* extensions) { | 1491 v8::ExtensionConfiguration* extensions) { |
1488 // Link this genesis object into the stacked genesis chain. This | 1492 // Link this genesis object into the stacked genesis chain. This |
1489 // must be done before any early exits because the destructor | 1493 // must be done before any early exits because the destructor |
1490 // will always do unlinking. | 1494 // will always do unlinking. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 } | 1554 } |
1551 | 1555 |
1552 | 1556 |
1553 // Restore statics that are thread local. | 1557 // Restore statics that are thread local. |
1554 char* Genesis::RestoreState(char* from) { | 1558 char* Genesis::RestoreState(char* from) { |
1555 current_ = *reinterpret_cast<Genesis**>(from); | 1559 current_ = *reinterpret_cast<Genesis**>(from); |
1556 return from + sizeof(current_); | 1560 return from + sizeof(current_); |
1557 } | 1561 } |
1558 | 1562 |
1559 } } // namespace v8::internal | 1563 } } // namespace v8::internal |
OLD | NEW |