diff options
Diffstat (limited to 'deps/v8/src/runtime/runtime-function.cc')
-rw-r--r-- | deps/v8/src/runtime/runtime-function.cc | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/deps/v8/src/runtime/runtime-function.cc b/deps/v8/src/runtime/runtime-function.cc index 749e16b9ed..a368f1b14c 100644 --- a/deps/v8/src/runtime/runtime-function.cc +++ b/deps/v8/src/runtime/runtime-function.cc @@ -2,16 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/v8.h" +#include "src/runtime/runtime-utils.h" #include "src/accessors.h" #include "src/arguments.h" #include "src/compiler.h" #include "src/cpu-profiler.h" #include "src/deoptimizer.h" -#include "src/frames.h" +#include "src/frames-inl.h" #include "src/messages.h" -#include "src/runtime/runtime-utils.h" namespace v8 { namespace internal { @@ -328,9 +327,8 @@ RUNTIME_FUNCTION(Runtime_SetForceInlineFlag) { // Find the arguments of the JavaScript function invocation that called // into C++ code. Collect these in a newly allocated array of handles (possibly // prefixed by a number of empty handles). -static SmartArrayPointer<Handle<Object> > GetCallerArguments(Isolate* isolate, - int prefix_argc, - int* total_argc) { +static base::SmartArrayPointer<Handle<Object> > GetCallerArguments( + Isolate* isolate, int prefix_argc, int* total_argc) { // Find frame containing arguments passed to the caller. JavaScriptFrameIterator it(isolate); JavaScriptFrame* frame = it.frame(); @@ -355,7 +353,7 @@ static SmartArrayPointer<Handle<Object> > GetCallerArguments(Isolate* isolate, argument_count--; *total_argc = prefix_argc + argument_count; - SmartArrayPointer<Handle<Object> > param_data( + base::SmartArrayPointer<Handle<Object> > param_data( NewArray<Handle<Object> >(*total_argc)); bool should_deoptimize = false; for (int i = 0; i < argument_count; i++) { @@ -376,7 +374,7 @@ static SmartArrayPointer<Handle<Object> > GetCallerArguments(Isolate* isolate, int args_count = frame->ComputeParametersCount(); *total_argc = prefix_argc + args_count; - SmartArrayPointer<Handle<Object> > param_data( + base::SmartArrayPointer<Handle<Object> > param_data( NewArray<Handle<Object> >(*total_argc)); for (int i = 0; i < args_count; i++) { Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); @@ -401,7 +399,7 @@ RUNTIME_FUNCTION(Runtime_FunctionBindArguments) { bound_function->shared()->set_inferred_name(isolate->heap()->empty_string()); // Get all arguments of calling function (Function.prototype.bind). int argc = 0; - SmartArrayPointer<Handle<Object> > arguments = + base::SmartArrayPointer<Handle<Object> > arguments = GetCallerArguments(isolate, 0, &argc); // Don't count the this-arg. if (argc > 0) { @@ -443,9 +441,18 @@ RUNTIME_FUNCTION(Runtime_FunctionBindArguments) { // Update length. Have to remove the prototype first so that map migration // is happy about the number of fields. RUNTIME_ASSERT(bound_function->RemovePrototype()); + + // The new function should have the same [[Prototype]] as the bindee. Handle<Map> bound_function_map( isolate->native_context()->bound_function_map()); + PrototypeIterator iter(isolate, bindee); + Handle<Object> proto = PrototypeIterator::GetCurrent(iter); + if (bound_function_map->prototype() != *proto) { + bound_function_map = Map::TransitionToPrototype(bound_function_map, proto, + REGULAR_PROTOTYPE); + } JSObject::MigrateToMap(bound_function, bound_function_map); + Handle<String> length_string = isolate->factory()->length_string(); // These attributes must be kept in sync with how the bootstrapper // configures the bound_function_map retrieved above. @@ -494,7 +501,7 @@ RUNTIME_FUNCTION(Runtime_NewObjectFromBound) { !Handle<JSFunction>::cast(bound_function)->shared()->bound()); int total_argc = 0; - SmartArrayPointer<Handle<Object> > param_data = + base::SmartArrayPointer<Handle<Object> > param_data = GetCallerArguments(isolate, bound_argc, &total_argc); for (int i = 0; i < bound_argc; i++) { param_data[i] = Handle<Object>( @@ -526,12 +533,12 @@ RUNTIME_FUNCTION(Runtime_Call) { // If there are too many arguments, allocate argv via malloc. const int argv_small_size = 10; Handle<Object> argv_small_buffer[argv_small_size]; - SmartArrayPointer<Handle<Object> > argv_large_buffer; + base::SmartArrayPointer<Handle<Object> > argv_large_buffer; Handle<Object>* argv = argv_small_buffer; if (argc > argv_small_size) { argv = new Handle<Object>[argc]; if (argv == NULL) return isolate->StackOverflow(); - argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); + argv_large_buffer = base::SmartArrayPointer<Handle<Object> >(argv); } for (int i = 0; i < argc; ++i) { @@ -565,12 +572,12 @@ RUNTIME_FUNCTION(Runtime_Apply) { // If there are too many arguments, allocate argv via malloc. const int argv_small_size = 10; Handle<Object> argv_small_buffer[argv_small_size]; - SmartArrayPointer<Handle<Object> > argv_large_buffer; + base::SmartArrayPointer<Handle<Object> > argv_large_buffer; Handle<Object>* argv = argv_small_buffer; if (argc > argv_small_size) { argv = new Handle<Object>[argc]; if (argv == NULL) return isolate->StackOverflow(); - argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); + argv_large_buffer = base::SmartArrayPointer<Handle<Object> >(argv); } for (int i = 0; i < argc; ++i) { |