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 11048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11059 Representation result_rep = RepresentationFor(result_type); | 11059 Representation result_rep = RepresentationFor(result_type); |
11060 | 11060 |
11061 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || | 11061 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || |
11062 (right_rep.IsTagged() && !right_rep.IsSmi()); | 11062 (right_rep.IsTagged() && !right_rep.IsSmi()); |
11063 | 11063 |
11064 HInstruction* instr = NULL; | 11064 HInstruction* instr = NULL; |
11065 // Only the stub is allowed to call into the runtime, since otherwise we would | 11065 // Only the stub is allowed to call into the runtime, since otherwise we would |
11066 // inline several instructions (including the two pushes) for every tagged | 11066 // inline several instructions (including the two pushes) for every tagged |
11067 // operation in optimized code, which is more expensive, than a stub call. | 11067 // operation in optimized code, which is more expensive, than a stub call. |
11068 if (graph()->info()->IsStub() && is_non_primitive) { | 11068 if (graph()->info()->IsStub() && is_non_primitive) { |
11069 HValue* function = | 11069 Runtime::FunctionId function_id; |
11070 AddLoadJSBuiltin(BinaryOpIC::TokenToContextIndex(op, strength)); | 11070 switch (op) { |
11071 default: | |
11072 UNREACHABLE(); | |
Michael Starzinger
2015/09/10 11:43:24
Sneaky fall-through to convince compiler that func
| |
11073 case Token::ADD: | |
11074 function_id = | |
11075 is_strong(strength) ? Runtime::kAdd_Strong : Runtime::kAdd; | |
11076 break; | |
11077 case Token::SUB: | |
11078 function_id = is_strong(strength) ? Runtime::kSubtract_Strong | |
11079 : Runtime::kSubtract; | |
11080 break; | |
11081 case Token::MUL: | |
11082 function_id = is_strong(strength) ? Runtime::kMultiply_Strong | |
11083 : Runtime::kMultiply; | |
11084 break; | |
11085 case Token::DIV: | |
11086 function_id = | |
11087 is_strong(strength) ? Runtime::kDivide_Strong : Runtime::kDivide; | |
11088 break; | |
11089 case Token::MOD: | |
11090 function_id = | |
11091 is_strong(strength) ? Runtime::kModulus_Strong : Runtime::kModulus; | |
11092 break; | |
11093 case Token::BIT_OR: | |
11094 function_id = is_strong(strength) ? Runtime::kBitwiseOr_Strong | |
11095 : Runtime::kBitwiseOr; | |
11096 break; | |
11097 case Token::BIT_AND: | |
11098 function_id = is_strong(strength) ? Runtime::kBitwiseAnd_Strong | |
11099 : Runtime::kBitwiseAnd; | |
11100 break; | |
11101 case Token::BIT_XOR: | |
11102 function_id = is_strong(strength) ? Runtime::kBitwiseXor_Strong | |
11103 : Runtime::kBitwiseXor; | |
11104 break; | |
11105 case Token::SAR: | |
11106 function_id = is_strong(strength) ? Runtime::kShiftRight_Strong | |
11107 : Runtime::kShiftRight; | |
11108 break; | |
11109 case Token::SHR: | |
11110 function_id = is_strong(strength) ? Runtime::kShiftRightLogical_Strong | |
11111 : Runtime::kShiftRightLogical; | |
11112 break; | |
11113 case Token::SHL: | |
11114 function_id = is_strong(strength) ? Runtime::kShiftLeft_Strong | |
11115 : Runtime::kShiftLeft; | |
11116 break; | |
11117 } | |
11071 Add<HPushArguments>(left, right); | 11118 Add<HPushArguments>(left, right); |
11072 instr = AddUncasted<HInvokeFunction>(function, 2); | 11119 instr = AddUncasted<HCallRuntime>(Runtime::FunctionForId(function_id), 2); |
11073 } else { | 11120 } else { |
11074 if (is_strong(strength) && Token::IsBitOp(op)) { | 11121 if (is_strong(strength) && Token::IsBitOp(op)) { |
11075 // TODO(conradw): This is not efficient, but is necessary to prevent | 11122 // TODO(conradw): This is not efficient, but is necessary to prevent |
11076 // conversion of oddball values to numbers in strong mode. It would be | 11123 // conversion of oddball values to numbers in strong mode. It would be |
11077 // better to prevent the conversion rather than adding a runtime check. | 11124 // better to prevent the conversion rather than adding a runtime check. |
11078 IfBuilder if_builder(this); | 11125 IfBuilder if_builder(this); |
11079 if_builder.If<HHasInstanceTypeAndBranch>(left, ODDBALL_TYPE); | 11126 if_builder.If<HHasInstanceTypeAndBranch>(left, ODDBALL_TYPE); |
11080 if_builder.OrIf<HHasInstanceTypeAndBranch>(right, ODDBALL_TYPE); | 11127 if_builder.OrIf<HHasInstanceTypeAndBranch>(right, ODDBALL_TYPE); |
11081 if_builder.Then(); | 11128 if_builder.Then(); |
11082 Add<HCallRuntime>( | 11129 Add<HCallRuntime>( |
(...skipping 29 matching lines...) Expand all Loading... | |
11112 break; | 11159 break; |
11113 } | 11160 } |
11114 case Token::DIV: | 11161 case Token::DIV: |
11115 instr = AddUncasted<HDiv>(left, right, strength); | 11162 instr = AddUncasted<HDiv>(left, right, strength); |
11116 break; | 11163 break; |
11117 case Token::BIT_XOR: | 11164 case Token::BIT_XOR: |
11118 case Token::BIT_AND: | 11165 case Token::BIT_AND: |
11119 instr = AddUncasted<HBitwise>(op, left, right, strength); | 11166 instr = AddUncasted<HBitwise>(op, left, right, strength); |
11120 break; | 11167 break; |
11121 case Token::BIT_OR: { | 11168 case Token::BIT_OR: { |
11122 HValue* operand, *shift_amount; | 11169 HValue *operand, *shift_amount; |
11123 if (left_type->Is(Type::Signed32()) && | 11170 if (left_type->Is(Type::Signed32()) && |
11124 right_type->Is(Type::Signed32()) && | 11171 right_type->Is(Type::Signed32()) && |
11125 MatchRotateRight(left, right, &operand, &shift_amount)) { | 11172 MatchRotateRight(left, right, &operand, &shift_amount)) { |
11126 instr = AddUncasted<HRor>(operand, shift_amount, strength); | 11173 instr = AddUncasted<HRor>(operand, shift_amount, strength); |
11127 } else { | 11174 } else { |
11128 instr = AddUncasted<HBitwise>(op, left, right, strength); | 11175 instr = AddUncasted<HBitwise>(op, left, right, strength); |
11129 } | 11176 } |
11130 break; | 11177 break; |
11131 } | 11178 } |
11132 case Token::SAR: | 11179 case Token::SAR: |
(...skipping 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13496 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13543 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13497 } | 13544 } |
13498 | 13545 |
13499 #ifdef DEBUG | 13546 #ifdef DEBUG |
13500 graph_->Verify(false); // No full verify. | 13547 graph_->Verify(false); // No full verify. |
13501 #endif | 13548 #endif |
13502 } | 13549 } |
13503 | 13550 |
13504 } // namespace internal | 13551 } // namespace internal |
13505 } // namespace v8 | 13552 } // namespace v8 |
OLD | NEW |