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

Unified Diff: src/runtime/runtime-scopes.cc

Issue 1543253002: Basic TurboFan support for rest arguments. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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
Index: src/runtime/runtime-scopes.cc
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc
index 16917f9da5fa337533c192308ef50ad5f82c4a6c..275099fc3a3d389f4a119596217998be95dafdb2 100644
--- a/src/runtime/runtime-scopes.cc
+++ b/src/runtime/runtime-scopes.cc
@@ -521,6 +521,26 @@ Handle<JSObject> NewStrictArguments(Isolate* isolate, Handle<JSFunction> callee,
}
+template <typename T>
+Handle<JSObject> NewStrictRestArguments(Isolate* isolate,
Benedikt Meurer 2015/12/27 07:34:30 Same here: NewRestArguments.
mvstanton 2015/12/31 11:26:59 Done.
+ Handle<JSFunction> callee, T parameters,
+ int argument_count, int start_index) {
+ int num_elements = std::max(0, argument_count - start_index);
+ Handle<JSObject> result = isolate->factory()->NewJSArray(
+ FAST_ELEMENTS, num_elements, num_elements, Strength::WEAK,
+ DONT_INITIALIZE_ARRAY_ELEMENTS);
+ {
+ DisallowHeapAllocation no_gc;
+ FixedArray* elements = FixedArray::cast(result->elements());
+ WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
+ for (int i = 0; i < num_elements; i++) {
+ elements->set(i, parameters[i + start_index], mode);
+ }
+ }
+ return result;
+}
+
+
class HandleArguments BASE_EMBEDDED {
public:
explicit HandleArguments(Handle<Object>* array) : array_(array) {}
@@ -571,6 +591,22 @@ RUNTIME_FUNCTION(Runtime_NewStrictArguments_Generic) {
}
+RUNTIME_FUNCTION(Runtime_NewStrictRestArguments_Generic) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0)
+ CONVERT_SMI_ARG_CHECKED(start_index, 1);
+ // This generic runtime function can also be used when the caller has been
+ // inlined, we use the slow but accurate {Runtime::GetCallerArguments}.
+ int argument_count = 0;
+ base::SmartArrayPointer<Handle<Object>> arguments =
+ Runtime::GetCallerArguments(isolate, 0, &argument_count);
+ HandleArguments argument_getter(arguments.get());
+ return *NewStrictRestArguments(isolate, callee, argument_getter,
+ argument_count, start_index);
+}
+
+
RUNTIME_FUNCTION(Runtime_NewSloppyArguments) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);

Powered by Google App Engine
This is Rietveld 408576698