Index: src/crankshaft/hydrogen.cc |
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc |
index 57478f7cc6a504fc6f38e5ace3f8aa1f2d9759d8..e7415120b005176be13363ef190fd7eea925c99d 100644 |
--- a/src/crankshaft/hydrogen.cc |
+++ b/src/crankshaft/hydrogen.cc |
@@ -6334,15 +6334,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()) { |
@@ -6580,7 +6580,8 @@ HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess( |
Push(value); |
} |
- if (info->NeedsWrappingFor(info->accessor())) { |
+ if (info->accessor()->IsJSFunction() && |
+ info->NeedsWrappingFor(Handle<JSFunction>::cast(info->accessor()))) { |
Toon Verwaest
2016/01/28 12:05:19
If you could get a FunctionTemplate here, shouldn'
epertoso
2016/02/01 16:18:03
Technically, it seems unlikely that TryInlineGette
|
HValue* function = Add<HConstant>(info->accessor()); |
PushArgumentsFromEnvironment(argument_count); |
return New<HCallFunction>(function, argument_count, |
@@ -6595,7 +6596,9 @@ HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess( |
} |
PushArgumentsFromEnvironment(argument_count); |
- return BuildCallConstantFunction(info->accessor(), argument_count); |
+ DCHECK(info->accessor()->IsJSFunction()); |
+ return BuildCallConstantFunction(Handle<JSFunction>::cast(info->accessor()), |
+ argument_count); |
} |
DCHECK(info->IsDataConstant()); |
@@ -8627,24 +8630,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); |
} |
@@ -9138,8 +9142,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()); |
@@ -9152,8 +9155,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()); |
@@ -9166,15 +9168,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); |
@@ -9189,8 +9190,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; |
@@ -9270,7 +9274,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()); |