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

Unified Diff: src/builtins.cc

Issue 1816553002: Introduce a code stub version of Array.prototype.push (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 4 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/arm64/interface-descriptors-arm64.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 7c4124b0b3b028d9d2fe0e4b1d15f3caec2b36d4..14a1f9984cfebe6f5d6da8b5a11ec98047984ae4 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -420,7 +420,10 @@ BUILTIN(ObjectHasOwnProperty) {
return isolate->heap()->false_value();
}
-BUILTIN(ArrayPush) {
+namespace {
+
+Object* DoArrayPush(Isolate* isolate,
+ BuiltinArguments<BuiltinExtraArguments::kNone> args) {
HandleScope scope(isolate);
Handle<Object> receiver = args.receiver();
if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1)) {
@@ -444,6 +447,20 @@ BUILTIN(ArrayPush) {
return Smi::FromInt(new_length);
}
+} // namespace
+
+BUILTIN(ArrayPush) { return DoArrayPush(isolate, args); }
+
+// TODO(verwaest): This is a temporary helper until the FastArrayPush stub can
+// tailcall to the builtin directly.
+RUNTIME_FUNCTION(Runtime_ArrayPush) {
+ DCHECK_EQ(2, args.length());
+ Arguments* incoming = reinterpret_cast<Arguments*>(args[0]);
+ // Rewrap the arguments as builtins arguments.
+ BuiltinArguments<BuiltinExtraArguments::kNone> caller_args(
+ incoming->length() + 1, incoming->arguments() + 1);
+ return DoArrayPush(isolate, caller_args);
+}
BUILTIN(ArrayPop) {
HandleScope scope(isolate);
« no previous file with comments | « src/arm64/interface-descriptors-arm64.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698