| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
| 10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
| (...skipping 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 { | 2072 { |
| 2073 // Determine {receiver} map and instance type. | 2073 // Determine {receiver} map and instance type. |
| 2074 HValue* receiver_map = | 2074 HValue* receiver_map = |
| 2075 Add<HLoadNamedField>(receiver, nullptr, HObjectAccess::ForMap()); | 2075 Add<HLoadNamedField>(receiver, nullptr, HObjectAccess::ForMap()); |
| 2076 HValue* receiver_instance_type = Add<HLoadNamedField>( | 2076 HValue* receiver_instance_type = Add<HLoadNamedField>( |
| 2077 receiver_map, nullptr, HObjectAccess::ForMapInstanceType()); | 2077 receiver_map, nullptr, HObjectAccess::ForMapInstanceType()); |
| 2078 | 2078 |
| 2079 // First check whether {receiver} is already a spec object (fast case). | 2079 // First check whether {receiver} is already a spec object (fast case). |
| 2080 IfBuilder receiver_is_not_spec_object(this); | 2080 IfBuilder receiver_is_not_spec_object(this); |
| 2081 receiver_is_not_spec_object.If<HCompareNumericAndBranch>( | 2081 receiver_is_not_spec_object.If<HCompareNumericAndBranch>( |
| 2082 receiver_instance_type, Add<HConstant>(FIRST_SPEC_OBJECT_TYPE), | 2082 receiver_instance_type, Add<HConstant>(FIRST_JS_RECEIVER_TYPE), |
| 2083 Token::LT); | 2083 Token::LT); |
| 2084 receiver_is_not_spec_object.Then(); | 2084 receiver_is_not_spec_object.Then(); |
| 2085 { | 2085 { |
| 2086 // Load the constructor function index from the {receiver} map. | 2086 // Load the constructor function index from the {receiver} map. |
| 2087 HValue* constructor_function_index = Add<HLoadNamedField>( | 2087 HValue* constructor_function_index = Add<HLoadNamedField>( |
| 2088 receiver_map, nullptr, | 2088 receiver_map, nullptr, |
| 2089 HObjectAccess::ForMapInObjectPropertiesOrConstructorFunctionIndex()); | 2089 HObjectAccess::ForMapInObjectPropertiesOrConstructorFunctionIndex()); |
| 2090 | 2090 |
| 2091 // Check if {receiver} has a constructor (null and undefined have no | 2091 // Check if {receiver} has a constructor (null and undefined have no |
| 2092 // constructors, so we deoptimize to the runtime to throw an exception). | 2092 // constructors, so we deoptimize to the runtime to throw an exception). |
| (...skipping 2863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4956 } else if (context->IsEffect()) { | 4956 } else if (context->IsEffect()) { |
| 4957 CHECK_ALIVE(VisitForEffect(stmt->expression())); | 4957 CHECK_ALIVE(VisitForEffect(stmt->expression())); |
| 4958 Goto(function_return(), state); | 4958 Goto(function_return(), state); |
| 4959 } else { | 4959 } else { |
| 4960 DCHECK(context->IsValue()); | 4960 DCHECK(context->IsValue()); |
| 4961 CHECK_ALIVE(VisitForValue(stmt->expression())); | 4961 CHECK_ALIVE(VisitForValue(stmt->expression())); |
| 4962 HValue* return_value = Pop(); | 4962 HValue* return_value = Pop(); |
| 4963 HValue* receiver = environment()->arguments_environment()->Lookup(0); | 4963 HValue* receiver = environment()->arguments_environment()->Lookup(0); |
| 4964 HHasInstanceTypeAndBranch* typecheck = | 4964 HHasInstanceTypeAndBranch* typecheck = |
| 4965 New<HHasInstanceTypeAndBranch>(return_value, | 4965 New<HHasInstanceTypeAndBranch>(return_value, |
| 4966 FIRST_SPEC_OBJECT_TYPE, | 4966 FIRST_JS_RECEIVER_TYPE, |
| 4967 LAST_SPEC_OBJECT_TYPE); | 4967 LAST_JS_RECEIVER_TYPE); |
| 4968 HBasicBlock* if_spec_object = graph()->CreateBasicBlock(); | 4968 HBasicBlock* if_spec_object = graph()->CreateBasicBlock(); |
| 4969 HBasicBlock* not_spec_object = graph()->CreateBasicBlock(); | 4969 HBasicBlock* not_spec_object = graph()->CreateBasicBlock(); |
| 4970 typecheck->SetSuccessorAt(0, if_spec_object); | 4970 typecheck->SetSuccessorAt(0, if_spec_object); |
| 4971 typecheck->SetSuccessorAt(1, not_spec_object); | 4971 typecheck->SetSuccessorAt(1, not_spec_object); |
| 4972 FinishCurrentBlock(typecheck); | 4972 FinishCurrentBlock(typecheck); |
| 4973 AddLeaveInlined(if_spec_object, return_value, state); | 4973 AddLeaveInlined(if_spec_object, return_value, state); |
| 4974 AddLeaveInlined(not_spec_object, receiver, state); | 4974 AddLeaveInlined(not_spec_object, receiver, state); |
| 4975 } | 4975 } |
| 4976 } else if (state->inlining_kind() == SETTER_CALL_RETURN) { | 4976 } else if (state->inlining_kind() == SETTER_CALL_RETURN) { |
| 4977 // Return from an inlined setter call. The returned value is never used, the | 4977 // Return from an inlined setter call. The returned value is never used, the |
| (...skipping 7158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12136 return ast_context()->ReturnControl(result, call->id()); | 12136 return ast_context()->ReturnControl(result, call->id()); |
| 12137 } | 12137 } |
| 12138 | 12138 |
| 12139 | 12139 |
| 12140 void HOptimizedGraphBuilder::GenerateIsSpecObject(CallRuntime* call) { | 12140 void HOptimizedGraphBuilder::GenerateIsSpecObject(CallRuntime* call) { |
| 12141 DCHECK(call->arguments()->length() == 1); | 12141 DCHECK(call->arguments()->length() == 1); |
| 12142 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12142 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 12143 HValue* value = Pop(); | 12143 HValue* value = Pop(); |
| 12144 HHasInstanceTypeAndBranch* result = | 12144 HHasInstanceTypeAndBranch* result = |
| 12145 New<HHasInstanceTypeAndBranch>(value, | 12145 New<HHasInstanceTypeAndBranch>(value, |
| 12146 FIRST_SPEC_OBJECT_TYPE, | 12146 FIRST_JS_RECEIVER_TYPE, |
| 12147 LAST_SPEC_OBJECT_TYPE); | 12147 LAST_JS_RECEIVER_TYPE); |
| 12148 return ast_context()->ReturnControl(result, call->id()); | 12148 return ast_context()->ReturnControl(result, call->id()); |
| 12149 } | 12149 } |
| 12150 | 12150 |
| 12151 | 12151 |
| 12152 void HOptimizedGraphBuilder::GenerateIsFunction(CallRuntime* call) { | 12152 void HOptimizedGraphBuilder::GenerateIsFunction(CallRuntime* call) { |
| 12153 DCHECK(call->arguments()->length() == 1); | 12153 DCHECK(call->arguments()->length() == 1); |
| 12154 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12154 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 12155 HValue* value = Pop(); | 12155 HValue* value = Pop(); |
| 12156 HHasInstanceTypeAndBranch* result = | 12156 HHasInstanceTypeAndBranch* result = |
| 12157 New<HHasInstanceTypeAndBranch>(value, JS_FUNCTION_TYPE); | 12157 New<HHasInstanceTypeAndBranch>(value, JS_FUNCTION_TYPE); |
| (...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13619 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13619 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13620 } | 13620 } |
| 13621 | 13621 |
| 13622 #ifdef DEBUG | 13622 #ifdef DEBUG |
| 13623 graph_->Verify(false); // No full verify. | 13623 graph_->Verify(false); // No full verify. |
| 13624 #endif | 13624 #endif |
| 13625 } | 13625 } |
| 13626 | 13626 |
| 13627 } // namespace internal | 13627 } // namespace internal |
| 13628 } // namespace v8 | 13628 } // namespace v8 |
| OLD | NEW |