Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 // Copy arguments, skipping the first which is "this_arg". | 436 // Copy arguments, skipping the first which is "this_arg". |
| 437 for (int j = 0; j < argc; j++, i++) { | 437 for (int j = 0; j < argc; j++, i++) { |
| 438 new_bindings->set(i, *arguments[j + 1]); | 438 new_bindings->set(i, *arguments[j + 1]); |
| 439 } | 439 } |
| 440 new_bindings->set_map_no_write_barrier(isolate->heap()->fixed_array_map()); | 440 new_bindings->set_map_no_write_barrier(isolate->heap()->fixed_array_map()); |
| 441 bound_function->set_function_bindings(*new_bindings); | 441 bound_function->set_function_bindings(*new_bindings); |
| 442 | 442 |
| 443 // Update length. Have to remove the prototype first so that map migration | 443 // Update length. Have to remove the prototype first so that map migration |
| 444 // is happy about the number of fields. | 444 // is happy about the number of fields. |
| 445 RUNTIME_ASSERT(bound_function->RemovePrototype()); | 445 RUNTIME_ASSERT(bound_function->RemovePrototype()); |
| 446 Handle<Map> bound_function_map( | 446 |
| 447 isolate->native_context()->bound_function_map()); | 447 // The new function should have the same [[Prototype]] as the bindee. |
| 448 Handle<Map> bound_function_map = Map::Copy( | |
|
adamk
2015/07/01 19:31:55
Forcing map creation here seems possibly bad. If y
arv (Not doing code reviews)
2015/07/01 19:51:21
Done.
| |
| 449 handle(isolate->native_context()->bound_function_map()), "FunctionBind"); | |
| 450 PrototypeIterator iter(isolate, bindee); | |
| 451 Map::SetPrototype(bound_function_map, PrototypeIterator::GetCurrent(iter)); | |
| 448 JSObject::MigrateToMap(bound_function, bound_function_map); | 452 JSObject::MigrateToMap(bound_function, bound_function_map); |
| 453 | |
| 449 Handle<String> length_string = isolate->factory()->length_string(); | 454 Handle<String> length_string = isolate->factory()->length_string(); |
| 450 PropertyAttributes attr = | 455 PropertyAttributes attr = |
| 451 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); | 456 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); |
| 452 RETURN_FAILURE_ON_EXCEPTION( | 457 RETURN_FAILURE_ON_EXCEPTION( |
| 453 isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 458 isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
| 454 bound_function, length_string, new_length, attr)); | 459 bound_function, length_string, new_length, attr)); |
| 455 return *bound_function; | 460 return *bound_function; |
| 456 } | 461 } |
| 457 | 462 |
| 458 | 463 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 | 630 |
| 626 | 631 |
| 627 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { | 632 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { |
| 628 HandleScope scope(isolate); | 633 HandleScope scope(isolate); |
| 629 DCHECK(args.length() == 0); | 634 DCHECK(args.length() == 0); |
| 630 THROW_NEW_ERROR_RETURN_FAILURE(isolate, | 635 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
| 631 NewTypeError(MessageTemplate::kStrongArity)); | 636 NewTypeError(MessageTemplate::kStrongArity)); |
| 632 } | 637 } |
| 633 } // namespace internal | 638 } // namespace internal |
| 634 } // namespace v8 | 639 } // namespace v8 |
| OLD | NEW |