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

Side by Side Diff: src/builtins.cc

Issue 1756973002: Reland "[api] Don't go to javascript to construct API functions" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 4135 matching lines...) Expand 10 before | Expand all | Expand 10 after
4146 if (length() == 0) return; 4146 if (length() == 0) return;
4147 v->VisitPointers(lowest_address(), highest_address() + 1); 4147 v->VisitPointers(lowest_address(), highest_address() + 1);
4148 } 4148 }
4149 4149
4150 private: 4150 private:
4151 DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); 4151 DISALLOW_COPY_AND_ASSIGN(RelocatableArguments);
4152 }; 4152 };
4153 4153
4154 } // namespace 4154 } // namespace
4155 4155
4156 MaybeHandle<Object> Builtins::InvokeApiFunction(Handle<HeapObject> function, 4156 MaybeHandle<Object> Builtins::InvokeApiFunction(bool is_construct,
4157 Handle<HeapObject> function,
4157 Handle<Object> receiver, 4158 Handle<Object> receiver,
4158 int argc, 4159 int argc,
4159 Handle<Object> args[]) { 4160 Handle<Object> args[]) {
4160 // Construct BuiltinArguments object: function, arguments reversed, receiver. 4161 // Construct BuiltinArguments object: function, arguments reversed, receiver.
4161 const int kBufferSize = 32; 4162 const int kBufferSize = 32;
4162 Object* small_argv[kBufferSize]; 4163 Object* small_argv[kBufferSize];
4163 Object** argv; 4164 Object** argv;
4164 if (argc + 2 <= kBufferSize) { 4165 if (argc + 2 <= kBufferSize) {
4165 argv = small_argv; 4166 argv = small_argv;
4166 } else { 4167 } else {
4167 argv = new Object* [argc + 2]; 4168 argv = new Object* [argc + 2];
4168 } 4169 }
4169 argv[argc + 1] = *receiver; 4170 argv[argc + 1] = *receiver;
4170 for (int i = 0; i < argc; ++i) { 4171 for (int i = 0; i < argc; ++i) {
4171 argv[argc - i] = *args[i]; 4172 argv[argc - i] = *args[i];
4172 } 4173 }
4173 argv[0] = *function; 4174 argv[0] = *function;
4174 MaybeHandle<Object> result; 4175 MaybeHandle<Object> result;
4175 { 4176 {
4176 auto isolate = function->GetIsolate(); 4177 auto isolate = function->GetIsolate();
4177 RelocatableArguments arguments(isolate, argc + 2, &argv[argc + 1]); 4178 RelocatableArguments arguments(isolate, argc + 2, &argv[argc + 1]);
4178 result = HandleApiCallHelper<false>(isolate, arguments); 4179 result = is_construct ? HandleApiCallHelper<true>(isolate, arguments)
4180 : HandleApiCallHelper<false>(isolate, arguments);
4179 } 4181 }
4180 if (argv != small_argv) { 4182 if (argv != small_argv) {
4181 delete[] argv; 4183 delete[] argv;
4182 } 4184 }
4183 return result; 4185 return result;
4184 } 4186 }
4185 4187
4186 4188
4187 // Helper function to handle calls to non-function objects created through the 4189 // Helper function to handle calls to non-function objects created through the
4188 // API. The object can be called as either a constructor (using new) or just as 4190 // API. The object can be called as either a constructor (using new) or just as
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
4584 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 4586 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
4585 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 4587 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
4586 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 4588 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
4587 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 4589 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
4588 #undef DEFINE_BUILTIN_ACCESSOR_C 4590 #undef DEFINE_BUILTIN_ACCESSOR_C
4589 #undef DEFINE_BUILTIN_ACCESSOR_A 4591 #undef DEFINE_BUILTIN_ACCESSOR_A
4590 4592
4591 4593
4592 } // namespace internal 4594 } // namespace internal
4593 } // namespace v8 4595 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/execution.cc » ('j') | src/execution.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698