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

Unified Diff: src/runtime.cc

Issue 762001: Assign specialized array functions only once. (Closed)
Patch Set: Created 10 years, 9 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 | « src/runtime.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index e8abdef7f5c17f27468cf1ef7901206b3dc7b281..0255e6db32f23b003038d5619d37fcbd6d7257cd 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1242,6 +1242,38 @@ static Object* Runtime_FinishArrayPrototypeSetup(Arguments args) {
}
+static Handle<JSFunction> InstallFunction(Handle<JSObject> holder,
+ const char* name,
+ Builtins::Name builtin_name) {
+ Handle<String> key = Factory::LookupAsciiSymbol(name);
+ Handle<Code> code(Builtins::builtin(builtin_name));
+ Handle<JSFunction> optimized = Factory::NewFunction(key,
+ JS_OBJECT_TYPE,
+ JSObject::kHeaderSize,
+ code,
+ false);
+ optimized->shared()->DontAdaptArguments();
+ SetProperty(holder, key, optimized, NONE);
+ return optimized;
+}
+
+
+static Object* Runtime_SpecialArrayFunctions(Arguments args) {
+ HandleScope scope;
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_CHECKED(JSObject, holder, 0);
+
+ InstallFunction(holder, "pop", Builtins::ArrayPop);
+ InstallFunction(holder, "push", Builtins::ArrayPush);
+ InstallFunction(holder, "shift", Builtins::ArrayShift);
+ InstallFunction(holder, "unshift", Builtins::ArrayUnshift);
+ InstallFunction(holder, "slice", Builtins::ArraySlice);
+ InstallFunction(holder, "splice", Builtins::ArraySplice);
+
+ return *holder;
+}
+
+
static Object* Runtime_MaterializeRegExpLiteral(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698