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/hydrogen.h" | 5 #include "src/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-numbering.h" | 10 #include "src/ast-numbering.h" |
(...skipping 3490 matching lines...) Loading... |
3501 | 3501 |
3502 if (fill_mode == FILL_WITH_HOLE) { | 3502 if (fill_mode == FILL_WITH_HOLE) { |
3503 builder()->BuildFillElementsWithHole(elements_location_, kind_, | 3503 builder()->BuildFillElementsWithHole(elements_location_, kind_, |
3504 graph()->GetConstant0(), capacity); | 3504 graph()->GetConstant0(), capacity); |
3505 } | 3505 } |
3506 | 3506 |
3507 return array_object; | 3507 return array_object; |
3508 } | 3508 } |
3509 | 3509 |
3510 | 3510 |
3511 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { | 3511 HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) { |
3512 HValue* global_object = Add<HLoadNamedField>( | 3512 HValue* global_object = Add<HLoadNamedField>( |
3513 context(), nullptr, | 3513 context(), nullptr, |
3514 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 3514 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
3515 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( | 3515 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( |
3516 GlobalObject::kBuiltinsOffset); | 3516 GlobalObject::kNativeContextOffset); |
3517 HValue* builtins = Add<HLoadNamedField>(global_object, nullptr, access); | 3517 HValue* native_context = Add<HLoadNamedField>(global_object, nullptr, access); |
3518 HObjectAccess function_access = HObjectAccess::ForObservableJSObjectOffset( | 3518 HObjectAccess function_access = HObjectAccess::ForContextSlot(context_index); |
3519 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); | 3519 return Add<HLoadNamedField>(native_context, nullptr, function_access); |
3520 return Add<HLoadNamedField>(builtins, nullptr, function_access); | |
3521 } | 3520 } |
3522 | 3521 |
3523 | 3522 |
3524 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) | 3523 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) |
3525 : HGraphBuilder(info), | 3524 : HGraphBuilder(info), |
3526 function_state_(NULL), | 3525 function_state_(NULL), |
3527 initial_function_state_(this, info, NORMAL_RETURN, 0), | 3526 initial_function_state_(this, info, NORMAL_RETURN, 0), |
3528 ast_context_(NULL), | 3527 ast_context_(NULL), |
3529 break_scope_(NULL), | 3528 break_scope_(NULL), |
3530 inlined_count_(0), | 3529 inlined_count_(0), |
(...skipping 7373 matching lines...) Loading... |
10904 if (right_type->Is(Type::String())) { | 10903 if (right_type->Is(Type::String())) { |
10905 right = BuildCheckString(right); | 10904 right = BuildCheckString(right); |
10906 } | 10905 } |
10907 | 10906 |
10908 // Convert left argument as necessary. | 10907 // Convert left argument as necessary. |
10909 if (left_type->Is(Type::Number())) { | 10908 if (left_type->Is(Type::Number())) { |
10910 DCHECK(right_type->Is(Type::String())); | 10909 DCHECK(right_type->Is(Type::String())); |
10911 left = BuildNumberToString(left, left_type); | 10910 left = BuildNumberToString(left, left_type); |
10912 } else if (!left_type->Is(Type::String())) { | 10911 } else if (!left_type->Is(Type::String())) { |
10913 DCHECK(right_type->Is(Type::String())); | 10912 DCHECK(right_type->Is(Type::String())); |
10914 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); | 10913 HValue* function = |
| 10914 AddLoadJSBuiltin(Context::STRING_ADD_RIGHT_BUILTIN_INDEX); |
10915 Add<HPushArguments>(left, right); | 10915 Add<HPushArguments>(left, right); |
10916 return AddUncasted<HInvokeFunction>(function, 2); | 10916 return AddUncasted<HInvokeFunction>(function, 2); |
10917 } | 10917 } |
10918 | 10918 |
10919 // Convert right argument as necessary. | 10919 // Convert right argument as necessary. |
10920 if (right_type->Is(Type::Number())) { | 10920 if (right_type->Is(Type::Number())) { |
10921 DCHECK(left_type->Is(Type::String())); | 10921 DCHECK(left_type->Is(Type::String())); |
10922 right = BuildNumberToString(right, right_type); | 10922 right = BuildNumberToString(right, right_type); |
10923 } else if (!right_type->Is(Type::String())) { | 10923 } else if (!right_type->Is(Type::String())) { |
10924 DCHECK(left_type->Is(Type::String())); | 10924 DCHECK(left_type->Is(Type::String())); |
10925 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); | 10925 HValue* function = |
| 10926 AddLoadJSBuiltin(Context::STRING_ADD_LEFT_BUILTIN_INDEX); |
10926 Add<HPushArguments>(left, right); | 10927 Add<HPushArguments>(left, right); |
10927 return AddUncasted<HInvokeFunction>(function, 2); | 10928 return AddUncasted<HInvokeFunction>(function, 2); |
10928 } | 10929 } |
10929 } | 10930 } |
10930 | 10931 |
10931 // Fast paths for empty constant strings. | 10932 // Fast paths for empty constant strings. |
10932 Handle<String> left_string = | 10933 Handle<String> left_string = |
10933 left->IsConstant() && HConstant::cast(left)->HasStringValue() | 10934 left->IsConstant() && HConstant::cast(left)->HasStringValue() |
10934 ? HConstant::cast(left)->StringValue() | 10935 ? HConstant::cast(left)->StringValue() |
10935 : Handle<String>(); | 10936 : Handle<String>(); |
(...skipping 47 matching lines...) Loading... |
10983 | 10984 |
10984 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || | 10985 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || |
10985 (right_rep.IsTagged() && !right_rep.IsSmi()); | 10986 (right_rep.IsTagged() && !right_rep.IsSmi()); |
10986 | 10987 |
10987 HInstruction* instr = NULL; | 10988 HInstruction* instr = NULL; |
10988 // Only the stub is allowed to call into the runtime, since otherwise we would | 10989 // Only the stub is allowed to call into the runtime, since otherwise we would |
10989 // inline several instructions (including the two pushes) for every tagged | 10990 // inline several instructions (including the two pushes) for every tagged |
10990 // operation in optimized code, which is more expensive, than a stub call. | 10991 // operation in optimized code, which is more expensive, than a stub call. |
10991 if (graph()->info()->IsStub() && is_non_primitive) { | 10992 if (graph()->info()->IsStub() && is_non_primitive) { |
10992 HValue* function = | 10993 HValue* function = |
10993 AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op, strength)); | 10994 AddLoadJSBuiltin(BinaryOpIC::TokenToContextIndex(op, strength)); |
10994 Add<HPushArguments>(left, right); | 10995 Add<HPushArguments>(left, right); |
10995 instr = AddUncasted<HInvokeFunction>(function, 2); | 10996 instr = AddUncasted<HInvokeFunction>(function, 2); |
10996 } else { | 10997 } else { |
10997 if (is_strong(strength) && Token::IsBitOp(op)) { | 10998 if (is_strong(strength) && Token::IsBitOp(op)) { |
10998 // TODO(conradw): This is not efficient, but is necessary to prevent | 10999 // TODO(conradw): This is not efficient, but is necessary to prevent |
10999 // conversion of oddball values to numbers in strong mode. It would be | 11000 // conversion of oddball values to numbers in strong mode. It would be |
11000 // better to prevent the conversion rather than adding a runtime check. | 11001 // better to prevent the conversion rather than adding a runtime check. |
11001 IfBuilder if_builder(this); | 11002 IfBuilder if_builder(this); |
11002 if_builder.If<HHasInstanceTypeAndBranch>(left, ODDBALL_TYPE); | 11003 if_builder.If<HHasInstanceTypeAndBranch>(left, ODDBALL_TYPE); |
11003 if_builder.OrIf<HHasInstanceTypeAndBranch>(right, ODDBALL_TYPE); | 11004 if_builder.OrIf<HHasInstanceTypeAndBranch>(right, ODDBALL_TYPE); |
(...skipping 341 matching lines...) Loading... |
11345 HHasInPrototypeChainAndBranch* result = | 11346 HHasInPrototypeChainAndBranch* result = |
11346 New<HHasInPrototypeChainAndBranch>(left, prototype); | 11347 New<HHasInPrototypeChainAndBranch>(left, prototype); |
11347 return ast_context()->ReturnControl(result, expr->id()); | 11348 return ast_context()->ReturnControl(result, expr->id()); |
11348 } | 11349 } |
11349 } | 11350 } |
11350 | 11351 |
11351 HInstanceOf* result = New<HInstanceOf>(left, right); | 11352 HInstanceOf* result = New<HInstanceOf>(left, right); |
11352 return ast_context()->ReturnInstruction(result, expr->id()); | 11353 return ast_context()->ReturnInstruction(result, expr->id()); |
11353 | 11354 |
11354 } else if (op == Token::IN) { | 11355 } else if (op == Token::IN) { |
11355 HValue* function = AddLoadJSBuiltin(Builtins::IN); | 11356 HValue* function = AddLoadJSBuiltin(Context::IN_BUILTIN_INDEX); |
11356 Add<HPushArguments>(left, right); | 11357 Add<HPushArguments>(left, right); |
11357 // TODO(olivf) InvokeFunction produces a check for the parameter count, | 11358 // TODO(olivf) InvokeFunction produces a check for the parameter count, |
11358 // even though we are certain to pass the correct number of arguments here. | 11359 // even though we are certain to pass the correct number of arguments here. |
11359 HInstruction* result = New<HInvokeFunction>(function, 2); | 11360 HInstruction* result = New<HInvokeFunction>(function, 2); |
11360 return ast_context()->ReturnInstruction(result, expr->id()); | 11361 return ast_context()->ReturnInstruction(result, expr->id()); |
11361 } | 11362 } |
11362 | 11363 |
11363 PushBeforeSimulateBehavior push_behavior = | 11364 PushBeforeSimulateBehavior push_behavior = |
11364 ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE | 11365 ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE |
11365 : PUSH_BEFORE_SIMULATE; | 11366 : PUSH_BEFORE_SIMULATE; |
(...skipping 2068 matching lines...) Loading... |
13434 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13435 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13435 } | 13436 } |
13436 | 13437 |
13437 #ifdef DEBUG | 13438 #ifdef DEBUG |
13438 graph_->Verify(false); // No full verify. | 13439 graph_->Verify(false); // No full verify. |
13439 #endif | 13440 #endif |
13440 } | 13441 } |
13441 | 13442 |
13442 } // namespace internal | 13443 } // namespace internal |
13443 } // namespace v8 | 13444 } // namespace v8 |
OLD | NEW |