Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: src/bootstrapper.cc

Issue 606017: Introduce builtin for Array.shift function. (Closed)
Patch Set: Next round of Mads' comments Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/builtins.h » ('j') | test/mjsunit/array-shift.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index e88861d52664468e06053b6019dfddba87b9f82e..045a63005e99f272fb0a312d5d4de707428d8551 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1473,25 +1473,27 @@ void Genesis::AddSpecialFunction(Handle<JSObject> prototype,
void Genesis::BuildSpecialFunctionTable() {
HandleScope scope;
Handle<JSObject> global = Handle<JSObject>(global_context()->global());
- // Add special versions for Array.prototype.pop and push.
+ // Add special versions for some Array.prototype functions.
Handle<JSFunction> function =
Handle<JSFunction>(
JSFunction::cast(global->GetProperty(Heap::Array_symbol())));
Handle<JSObject> visible_prototype =
Handle<JSObject>(JSObject::cast(function->prototype()));
- // Remember to put push and pop on the hidden prototype if it's there.
- Handle<JSObject> push_and_pop_prototype;
+ // Remember to put those specializations on the hidden prototype if present.
+ Handle<JSObject> special_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);
+ special_prototype = Handle<JSObject>::cast(superproto);
} else {
- push_and_pop_prototype = visible_prototype;
+ special_prototype = visible_prototype;
}
- AddSpecialFunction(push_and_pop_prototype, "pop",
+ AddSpecialFunction(special_prototype, "pop",
Handle<Code>(Builtins::builtin(Builtins::ArrayPop)));
- AddSpecialFunction(push_and_pop_prototype, "push",
+ AddSpecialFunction(special_prototype, "push",
Handle<Code>(Builtins::builtin(Builtins::ArrayPush)));
+ AddSpecialFunction(special_prototype, "shift",
+ Handle<Code>(Builtins::builtin(Builtins::ArrayShift)));
}
« no previous file with comments | « no previous file | src/builtins.h » ('j') | test/mjsunit/array-shift.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698