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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 1609233002: Do not eagerly instantiate accessors' JSFunction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make GCMole happy again. Created 4 years, 10 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/crankshaft/hydrogen.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index 0e9ac8ad45fff2e9e905300a49c5b75902de693d..37417db171e64278de8c0deb033025c93ae2c13a 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -6371,15 +6371,15 @@ bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) {
Object* raw_accessor =
IsLoad() ? Handle<AccessorPair>::cast(accessors)->getter()
: Handle<AccessorPair>::cast(accessors)->setter();
- if (!raw_accessor->IsJSFunction()) return false;
- Handle<JSFunction> accessor = handle(JSFunction::cast(raw_accessor));
- if (accessor->shared()->IsApiFunction()) {
- CallOptimization call_optimization(accessor);
- if (call_optimization.is_simple_api_call()) {
- CallOptimization::HolderLookup holder_lookup;
- api_holder_ =
- call_optimization.LookupHolderOfExpectedType(map_, &holder_lookup);
- }
+ if (!raw_accessor->IsJSFunction() &&
+ !raw_accessor->IsFunctionTemplateInfo())
+ return false;
+ Handle<Object> accessor = handle(HeapObject::cast(raw_accessor));
+ CallOptimization call_optimization(accessor);
+ if (call_optimization.is_simple_api_call()) {
+ CallOptimization::HolderLookup holder_lookup;
+ api_holder_ =
+ call_optimization.LookupHolderOfExpectedType(map_, &holder_lookup);
}
accessor_ = accessor;
} else if (IsDataConstant()) {
@@ -6617,7 +6617,8 @@ HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess(
Push(value);
}
- if (info->NeedsWrappingFor(info->accessor())) {
+ if (info->accessor()->IsJSFunction() &&
+ info->NeedsWrappingFor(Handle<JSFunction>::cast(info->accessor()))) {
HValue* function = Add<HConstant>(info->accessor());
PushArgumentsFromEnvironment(argument_count);
return New<HCallFunction>(function, argument_count,
@@ -6632,7 +6633,12 @@ HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess(
}
PushArgumentsFromEnvironment(argument_count);
- return BuildCallConstantFunction(info->accessor(), argument_count);
+ if (!info->accessor()->IsJSFunction()) {
+ Bailout(kInliningBailedOut);
+ return nullptr;
+ }
+ return BuildCallConstantFunction(Handle<JSFunction>::cast(info->accessor()),
+ argument_count);
}
DCHECK(info->IsDataConstant());
@@ -8666,24 +8672,25 @@ bool HOptimizedGraphBuilder::TryInlineConstruct(CallNew* expr,
CONSTRUCT_CALL_RETURN);
}
-
-bool HOptimizedGraphBuilder::TryInlineGetter(Handle<JSFunction> getter,
+bool HOptimizedGraphBuilder::TryInlineGetter(Handle<Object> getter,
Handle<Map> receiver_map,
BailoutId ast_id,
BailoutId return_id) {
if (TryInlineApiGetter(getter, receiver_map, ast_id)) return true;
- return TryInline(getter, 0, NULL, ast_id, return_id, GETTER_CALL_RETURN);
+ return getter->IsJSFunction() &&
+ TryInline(Handle<JSFunction>::cast(getter), 0, NULL, ast_id, return_id,
+ GETTER_CALL_RETURN);
}
-
-bool HOptimizedGraphBuilder::TryInlineSetter(Handle<JSFunction> setter,
+bool HOptimizedGraphBuilder::TryInlineSetter(Handle<Object> setter,
Handle<Map> receiver_map,
BailoutId id,
BailoutId assignment_id,
HValue* implicit_return_value) {
if (TryInlineApiSetter(setter, receiver_map, id)) return true;
- return TryInline(setter, 1, implicit_return_value, id, assignment_id,
- SETTER_CALL_RETURN);
+ return setter->IsJSFunction() &&
+ TryInline(Handle<JSFunction>::cast(setter), 1, implicit_return_value,
+ id, assignment_id, SETTER_CALL_RETURN);
}
@@ -9177,8 +9184,7 @@ bool HOptimizedGraphBuilder::TryInlineApiMethodCall(
kCallApiMethod);
}
-
-bool HOptimizedGraphBuilder::TryInlineApiGetter(Handle<JSFunction> function,
+bool HOptimizedGraphBuilder::TryInlineApiGetter(Handle<Object> function,
Handle<Map> receiver_map,
BailoutId ast_id) {
SmallMapList receiver_maps(1, zone());
@@ -9191,8 +9197,7 @@ bool HOptimizedGraphBuilder::TryInlineApiGetter(Handle<JSFunction> function,
kCallApiGetter);
}
-
-bool HOptimizedGraphBuilder::TryInlineApiSetter(Handle<JSFunction> function,
+bool HOptimizedGraphBuilder::TryInlineApiSetter(Handle<Object> function,
Handle<Map> receiver_map,
BailoutId ast_id) {
SmallMapList receiver_maps(1, zone());
@@ -9205,15 +9210,14 @@ bool HOptimizedGraphBuilder::TryInlineApiSetter(Handle<JSFunction> function,
kCallApiSetter);
}
-
-bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
- HValue* receiver,
- SmallMapList* receiver_maps,
- int argc,
- BailoutId ast_id,
- ApiCallType call_type) {
- if (function->context()->native_context() !=
- top_info()->closure()->context()->native_context()) {
+bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<Object> function,
+ HValue* receiver,
+ SmallMapList* receiver_maps,
+ int argc, BailoutId ast_id,
+ ApiCallType call_type) {
+ if (function->IsJSFunction() &&
+ Handle<JSFunction>::cast(function)->context()->native_context() !=
+ top_info()->closure()->context()->native_context()) {
return false;
}
CallOptimization optimization(function);
@@ -9228,8 +9232,11 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
// Cannot embed a direct reference to the global proxy map
// as it maybe dropped on deserialization.
CHECK(!isolate()->serializer_enabled());
+ DCHECK(function->IsJSFunction());
DCHECK_EQ(0, receiver_maps->length());
- receiver_maps->Add(handle(function->global_proxy()->map()), zone());
+ receiver_maps->Add(
+ handle(Handle<JSFunction>::cast(function)->global_proxy()->map()),
+ zone());
}
CallOptimization::HolderLookup holder_lookup =
CallOptimization::kHolderNotFound;
@@ -9309,7 +9316,8 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
HInstruction* call = nullptr;
if (!is_function) {
- CallApiAccessorStub stub(isolate(), is_store, call_data_undefined);
+ CallApiAccessorStub stub(isolate(), is_store, call_data_undefined,
+ !optimization.is_constant_call());
Handle<Code> code = stub.GetCode();
HConstant* code_value = Add<HConstant>(code);
ApiAccessorDescriptor descriptor(isolate());
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698