| 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 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 new_array->set(len+1, *value); | 1565 new_array->set(len+1, *value); |
| 1566 new_array->set(len+2, *optimized); | 1566 new_array->set(len+2, *optimized); |
| 1567 global_context()->set_special_function_table(*new_array); | 1567 global_context()->set_special_function_table(*new_array); |
| 1568 } | 1568 } |
| 1569 } | 1569 } |
| 1570 | 1570 |
| 1571 | 1571 |
| 1572 void Genesis::BuildSpecialFunctionTable() { | 1572 void Genesis::BuildSpecialFunctionTable() { |
| 1573 HandleScope scope; | 1573 HandleScope scope; |
| 1574 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); | 1574 Handle<JSObject> global = Handle<JSObject>(global_context()->global()); |
| 1575 // Add special versions for Array.prototype.pop and push. | 1575 // Add special versions for some Array.prototype functions. |
| 1576 Handle<JSFunction> function = | 1576 Handle<JSFunction> function = |
| 1577 Handle<JSFunction>( | 1577 Handle<JSFunction>( |
| 1578 JSFunction::cast(global->GetProperty(Heap::Array_symbol()))); | 1578 JSFunction::cast(global->GetProperty(Heap::Array_symbol()))); |
| 1579 Handle<JSObject> visible_prototype = | 1579 Handle<JSObject> visible_prototype = |
| 1580 Handle<JSObject>(JSObject::cast(function->prototype())); | 1580 Handle<JSObject>(JSObject::cast(function->prototype())); |
| 1581 // Remember to put push and pop on the hidden prototype if it's there. | 1581 // Remember to put those specializations on the hidden prototype if present. |
| 1582 Handle<JSObject> push_and_pop_prototype; | 1582 Handle<JSObject> special_prototype; |
| 1583 Handle<Object> superproto(visible_prototype->GetPrototype()); | 1583 Handle<Object> superproto(visible_prototype->GetPrototype()); |
| 1584 if (superproto->IsJSObject() && | 1584 if (superproto->IsJSObject() && |
| 1585 JSObject::cast(*superproto)->map()->is_hidden_prototype()) { | 1585 JSObject::cast(*superproto)->map()->is_hidden_prototype()) { |
| 1586 push_and_pop_prototype = Handle<JSObject>::cast(superproto); | 1586 special_prototype = Handle<JSObject>::cast(superproto); |
| 1587 } else { | 1587 } else { |
| 1588 push_and_pop_prototype = visible_prototype; | 1588 special_prototype = visible_prototype; |
| 1589 } | 1589 } |
| 1590 AddSpecialFunction(push_and_pop_prototype, "pop", | 1590 AddSpecialFunction(special_prototype, "pop", |
| 1591 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); | 1591 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); |
| 1592 AddSpecialFunction(push_and_pop_prototype, "push", | 1592 AddSpecialFunction(special_prototype, "push", |
| 1593 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); | 1593 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); |
| 1594 AddSpecialFunction(special_prototype, "shift", |
| 1595 Handle<Code>(Builtins::builtin(Builtins::ArrayShift))); |
| 1594 } | 1596 } |
| 1595 | 1597 |
| 1596 | 1598 |
| 1597 Genesis::Genesis(Handle<Object> global_object, | 1599 Genesis::Genesis(Handle<Object> global_object, |
| 1598 v8::Handle<v8::ObjectTemplate> global_template, | 1600 v8::Handle<v8::ObjectTemplate> global_template, |
| 1599 v8::ExtensionConfiguration* extensions) { | 1601 v8::ExtensionConfiguration* extensions) { |
| 1600 // Link this genesis object into the stacked genesis chain. This | 1602 // Link this genesis object into the stacked genesis chain. This |
| 1601 // must be done before any early exits because the destructor | 1603 // must be done before any early exits because the destructor |
| 1602 // will always do unlinking. | 1604 // will always do unlinking. |
| 1603 previous_ = current_; | 1605 previous_ = current_; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 } | 1671 } |
| 1670 | 1672 |
| 1671 | 1673 |
| 1672 // Restore statics that are thread local. | 1674 // Restore statics that are thread local. |
| 1673 char* Genesis::RestoreState(char* from) { | 1675 char* Genesis::RestoreState(char* from) { |
| 1674 current_ = *reinterpret_cast<Genesis**>(from); | 1676 current_ = *reinterpret_cast<Genesis**>(from); |
| 1675 return from + sizeof(current_); | 1677 return from + sizeof(current_); |
| 1676 } | 1678 } |
| 1677 | 1679 |
| 1678 } } // namespace v8::internal | 1680 } } // namespace v8::internal |
| OLD | NEW |