| 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
| (...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 MaybeHandle<JSObject>(), Builtins::kArrayConcat); | 2506 MaybeHandle<JSObject>(), Builtins::kArrayConcat); |
| 2507 | 2507 |
| 2508 // Make sure that InternalArray.prototype.concat appears to be compiled. | 2508 // Make sure that InternalArray.prototype.concat appears to be compiled. |
| 2509 // The code will never be called, but inline caching for call will | 2509 // The code will never be called, but inline caching for call will |
| 2510 // only work if it appears to be compiled. | 2510 // only work if it appears to be compiled. |
| 2511 concat->shared()->DontAdaptArguments(); | 2511 concat->shared()->DontAdaptArguments(); |
| 2512 DCHECK(concat->is_compiled()); | 2512 DCHECK(concat->is_compiled()); |
| 2513 // Set the lengths for the functions to satisfy ECMA-262. | 2513 // Set the lengths for the functions to satisfy ECMA-262. |
| 2514 concat->shared()->set_length(1); | 2514 concat->shared()->set_length(1); |
| 2515 } | 2515 } |
| 2516 // Install Function.prototype.call and apply. | 2516 // Install Function.prototype.apply, call, and toString. |
| 2517 { | 2517 { |
| 2518 Handle<String> key = factory()->Function_string(); | 2518 Handle<String> key = factory()->Function_string(); |
| 2519 Handle<JSFunction> function = | 2519 Handle<JSFunction> function = |
| 2520 Handle<JSFunction>::cast(Object::GetProperty( | 2520 Handle<JSFunction>::cast(Object::GetProperty( |
| 2521 handle(native_context()->global_object()), key).ToHandleChecked()); | 2521 handle(native_context()->global_object()), key).ToHandleChecked()); |
| 2522 Handle<JSObject> proto = | 2522 Handle<JSObject> proto = |
| 2523 Handle<JSObject>(JSObject::cast(function->instance_prototype())); | 2523 Handle<JSObject>(JSObject::cast(function->instance_prototype())); |
| 2524 | 2524 |
| 2525 // Install the call and the apply functions. | 2525 // Install the apply, call and toString functions. |
| 2526 Handle<JSFunction> call = | 2526 SimpleInstallFunction(proto, factory()->apply_string(), |
| 2527 InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 2527 Builtins::kFunctionPrototypeApply, 2, false); |
| 2528 MaybeHandle<JSObject>(), Builtins::kFunctionCall); | 2528 SimpleInstallFunction(proto, factory()->call_string(), |
| 2529 Handle<JSFunction> apply = | 2529 Builtins::kFunctionPrototypeCall, 1, false); |
| 2530 InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 2530 SimpleInstallFunction(proto, factory()->toString_string(), |
| 2531 MaybeHandle<JSObject>(), Builtins::kFunctionApply); | 2531 Builtins::kFunctionPrototypeToString, 0, false); |
| 2532 | |
| 2533 // Make sure that Function.prototype.call appears to be compiled. | |
| 2534 // The code will never be called, but inline caching for call will | |
| 2535 // only work if it appears to be compiled. | |
| 2536 apply->shared()->DontAdaptArguments(); | |
| 2537 call->shared()->DontAdaptArguments(); | |
| 2538 DCHECK(call->is_compiled()); | |
| 2539 | |
| 2540 // Set the lengths for the functions to satisfy ECMA-262. | |
| 2541 apply->shared()->set_length(2); | |
| 2542 call->shared()->set_length(1); | |
| 2543 } | 2532 } |
| 2544 | 2533 |
| 2545 // Set up the Promise constructor. | 2534 // Set up the Promise constructor. |
| 2546 { | 2535 { |
| 2547 Handle<String> key = factory()->Promise_string(); | 2536 Handle<String> key = factory()->Promise_string(); |
| 2548 Handle<JSFunction> function = Handle<JSFunction>::cast( | 2537 Handle<JSFunction> function = Handle<JSFunction>::cast( |
| 2549 Object::GetProperty(handle(native_context()->global_object()), key) | 2538 Object::GetProperty(handle(native_context()->global_object()), key) |
| 2550 .ToHandleChecked()); | 2539 .ToHandleChecked()); |
| 2551 JSFunction::EnsureHasInitialMap(function); | 2540 JSFunction::EnsureHasInitialMap(function); |
| 2552 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); | 2541 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3352 } | 3341 } |
| 3353 | 3342 |
| 3354 | 3343 |
| 3355 // Called when the top-level V8 mutex is destroyed. | 3344 // Called when the top-level V8 mutex is destroyed. |
| 3356 void Bootstrapper::FreeThreadResources() { | 3345 void Bootstrapper::FreeThreadResources() { |
| 3357 DCHECK(!IsActive()); | 3346 DCHECK(!IsActive()); |
| 3358 } | 3347 } |
| 3359 | 3348 |
| 3360 } // namespace internal | 3349 } // namespace internal |
| 3361 } // namespace v8 | 3350 } // namespace v8 |
| OLD | NEW |