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

Side by Side Diff: src/bootstrapper.cc

Issue 2044113002: Turn Function.prototype.bind into a hydrogen stub optimized for the common case (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: arm64 Created 4 years, 6 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
« no previous file with comments | « src/arm64/interface-descriptors-arm64.cc ('k') | src/builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 void Genesis::SetFunctionInstanceDescriptor(Handle<Map> map, 461 void Genesis::SetFunctionInstanceDescriptor(Handle<Map> map,
462 FunctionMode function_mode) { 462 FunctionMode function_mode) {
463 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4; 463 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4;
464 Map::EnsureDescriptorSlack(map, size); 464 Map::EnsureDescriptorSlack(map, size);
465 465
466 PropertyAttributes ro_attribs = 466 PropertyAttributes ro_attribs =
467 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 467 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
468 PropertyAttributes roc_attribs = 468 PropertyAttributes roc_attribs =
469 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); 469 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
470 470
471 STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
471 Handle<AccessorInfo> length = 472 Handle<AccessorInfo> length =
472 Accessors::FunctionLengthInfo(isolate(), roc_attribs); 473 Accessors::FunctionLengthInfo(isolate(), roc_attribs);
473 { // Add length. 474 { // Add length.
474 AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())), 475 AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())),
475 length, roc_attribs); 476 length, roc_attribs);
476 map->AppendDescriptor(&d); 477 map->AppendDescriptor(&d);
477 } 478 }
479
480 STATIC_ASSERT(JSFunction::kNameDescriptorIndex == 1);
478 Handle<AccessorInfo> name = 481 Handle<AccessorInfo> name =
479 Accessors::FunctionNameInfo(isolate(), ro_attribs); 482 Accessors::FunctionNameInfo(isolate(), ro_attribs);
480 { // Add name. 483 { // Add name.
481 AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name, 484 AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name,
482 roc_attribs); 485 roc_attribs);
483 map->AppendDescriptor(&d); 486 map->AppendDescriptor(&d);
484 } 487 }
485 Handle<AccessorInfo> args = 488 Handle<AccessorInfo> args =
486 Accessors::FunctionArgumentsInfo(isolate(), ro_attribs); 489 Accessors::FunctionArgumentsInfo(isolate(), ro_attribs);
487 { // Add arguments. 490 { // Add arguments.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 PropertyAttributes rw_attribs = 625 PropertyAttributes rw_attribs =
623 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 626 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
624 PropertyAttributes ro_attribs = 627 PropertyAttributes ro_attribs =
625 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 628 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
626 PropertyAttributes roc_attribs = 629 PropertyAttributes roc_attribs =
627 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); 630 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
628 631
629 DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE || 632 DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ||
630 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE || 633 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE ||
631 function_mode == FUNCTION_WITHOUT_PROTOTYPE); 634 function_mode == FUNCTION_WITHOUT_PROTOTYPE);
635 STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
632 { // Add length. 636 { // Add length.
633 Handle<AccessorInfo> length = 637 Handle<AccessorInfo> length =
634 Accessors::FunctionLengthInfo(isolate(), roc_attribs); 638 Accessors::FunctionLengthInfo(isolate(), roc_attribs);
635 AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())), 639 AccessorConstantDescriptor d(handle(Name::cast(length->name())), length,
636 length, roc_attribs); 640 roc_attribs);
637 map->AppendDescriptor(&d); 641 map->AppendDescriptor(&d);
638 } 642 }
643
644 STATIC_ASSERT(JSFunction::kNameDescriptorIndex == 1);
639 { // Add name. 645 { // Add name.
640 Handle<AccessorInfo> name = 646 Handle<AccessorInfo> name =
641 Accessors::FunctionNameInfo(isolate(), roc_attribs); 647 Accessors::FunctionNameInfo(isolate(), roc_attribs);
642 AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name, 648 AccessorConstantDescriptor d(handle(Name::cast(name->name())), name,
643 roc_attribs); 649 roc_attribs);
644 map->AppendDescriptor(&d); 650 map->AppendDescriptor(&d);
645 } 651 }
646 if (IsFunctionModeWithPrototype(function_mode)) { 652 if (IsFunctionModeWithPrototype(function_mode)) {
647 // Add prototype. 653 // Add prototype.
648 PropertyAttributes attribs = 654 PropertyAttributes attribs =
649 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs 655 function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ? rw_attribs
650 : ro_attribs; 656 : ro_attribs;
651 Handle<AccessorInfo> prototype = 657 Handle<AccessorInfo> prototype =
652 Accessors::FunctionPrototypeInfo(isolate(), attribs); 658 Accessors::FunctionPrototypeInfo(isolate(), attribs);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 function_fun->shared()->DontAdaptArguments(); 1182 function_fun->shared()->DontAdaptArguments();
1177 function_fun->shared()->set_construct_stub( 1183 function_fun->shared()->set_construct_stub(
1178 *isolate->builtins()->FunctionConstructor()); 1184 *isolate->builtins()->FunctionConstructor());
1179 function_fun->shared()->set_length(1); 1185 function_fun->shared()->set_length(1);
1180 InstallWithIntrinsicDefaultProto(isolate, function_fun, 1186 InstallWithIntrinsicDefaultProto(isolate, function_fun,
1181 Context::FUNCTION_FUNCTION_INDEX); 1187 Context::FUNCTION_FUNCTION_INDEX);
1182 1188
1183 // Setup the methods on the %FunctionPrototype%. 1189 // Setup the methods on the %FunctionPrototype%.
1184 SimpleInstallFunction(prototype, factory->apply_string(), 1190 SimpleInstallFunction(prototype, factory->apply_string(),
1185 Builtins::kFunctionPrototypeApply, 2, false); 1191 Builtins::kFunctionPrototypeApply, 2, false);
1186 SimpleInstallFunction(prototype, factory->bind_string(), 1192
1187 Builtins::kFunctionPrototypeBind, 1, false); 1193 FastFunctionBindStub bind_stub(isolate);
1194 Handle<JSFunction> bind_function = factory->NewFunctionWithoutPrototype(
1195 factory->bind_string(), bind_stub.GetCode(), false);
1196 bind_function->shared()->DontAdaptArguments();
1197 bind_function->shared()->set_length(1);
1198 InstallFunction(prototype, bind_function, factory->bind_string(),
1199 DONT_ENUM);
1200
1188 SimpleInstallFunction(prototype, factory->call_string(), 1201 SimpleInstallFunction(prototype, factory->call_string(),
1189 Builtins::kFunctionPrototypeCall, 1, false); 1202 Builtins::kFunctionPrototypeCall, 1, false);
1190 SimpleInstallFunction(prototype, factory->toString_string(), 1203 SimpleInstallFunction(prototype, factory->toString_string(),
1191 Builtins::kFunctionPrototypeToString, 0, false); 1204 Builtins::kFunctionPrototypeToString, 0, false);
1192 1205
1193 // Install the @@hasInstance function. 1206 // Install the @@hasInstance function.
1194 Handle<JSFunction> has_instance = InstallFunction( 1207 Handle<JSFunction> has_instance = InstallFunction(
1195 prototype, factory->has_instance_symbol(), JS_OBJECT_TYPE, 1208 prototype, factory->has_instance_symbol(), JS_OBJECT_TYPE,
1196 JSObject::kHeaderSize, MaybeHandle<JSObject>(), 1209 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
1197 Builtins::kFunctionPrototypeHasInstance, 1210 Builtins::kFunctionPrototypeHasInstance,
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3817 } 3830 }
3818 3831
3819 3832
3820 // Called when the top-level V8 mutex is destroyed. 3833 // Called when the top-level V8 mutex is destroyed.
3821 void Bootstrapper::FreeThreadResources() { 3834 void Bootstrapper::FreeThreadResources() {
3822 DCHECK(!IsActive()); 3835 DCHECK(!IsActive());
3823 } 3836 }
3824 3837
3825 } // namespace internal 3838 } // namespace internal
3826 } // namespace v8 3839 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/interface-descriptors-arm64.cc ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698