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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm64/interface-descriptors-arm64.cc ('k') | src/builtins.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 5e6ff7a9f6b910716221a63f4295137072d74b6b..4f91f4cf7162a158fffd6b7ae7f44ec861e2aa69 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -468,6 +468,7 @@ void Genesis::SetFunctionInstanceDescriptor(Handle<Map> map,
PropertyAttributes roc_attribs =
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
+ STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
Handle<AccessorInfo> length =
Accessors::FunctionLengthInfo(isolate(), roc_attribs);
{ // Add length.
@@ -475,6 +476,8 @@ void Genesis::SetFunctionInstanceDescriptor(Handle<Map> map,
length, roc_attribs);
map->AppendDescriptor(&d);
}
+
+ STATIC_ASSERT(JSFunction::kNameDescriptorIndex == 1);
Handle<AccessorInfo> name =
Accessors::FunctionNameInfo(isolate(), ro_attribs);
{ // Add name.
@@ -629,17 +632,20 @@ void Genesis::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ||
function_mode == FUNCTION_WITH_READONLY_PROTOTYPE ||
function_mode == FUNCTION_WITHOUT_PROTOTYPE);
+ STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
{ // Add length.
Handle<AccessorInfo> length =
Accessors::FunctionLengthInfo(isolate(), roc_attribs);
- AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())),
- length, roc_attribs);
+ AccessorConstantDescriptor d(handle(Name::cast(length->name())), length,
+ roc_attribs);
map->AppendDescriptor(&d);
}
+
+ STATIC_ASSERT(JSFunction::kNameDescriptorIndex == 1);
{ // Add name.
Handle<AccessorInfo> name =
Accessors::FunctionNameInfo(isolate(), roc_attribs);
- AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name,
+ AccessorConstantDescriptor d(handle(Name::cast(name->name())), name,
roc_attribs);
map->AppendDescriptor(&d);
}
@@ -1183,8 +1189,15 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// Setup the methods on the %FunctionPrototype%.
SimpleInstallFunction(prototype, factory->apply_string(),
Builtins::kFunctionPrototypeApply, 2, false);
- SimpleInstallFunction(prototype, factory->bind_string(),
- Builtins::kFunctionPrototypeBind, 1, false);
+
+ FastFunctionBindStub bind_stub(isolate);
+ Handle<JSFunction> bind_function = factory->NewFunctionWithoutPrototype(
+ factory->bind_string(), bind_stub.GetCode(), false);
+ bind_function->shared()->DontAdaptArguments();
+ bind_function->shared()->set_length(1);
+ InstallFunction(prototype, bind_function, factory->bind_string(),
+ DONT_ENUM);
+
SimpleInstallFunction(prototype, factory->call_string(),
Builtins::kFunctionPrototypeCall, 1, false);
SimpleInstallFunction(prototype, factory->toString_string(),
« 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