OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ic/ic.h" | 7 #include "src/ic/ic.h" |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 | 46 |
47 BinaryOpICState::BinaryOpICState(Isolate* isolate, ExtraICState extra_ic_state) | 47 BinaryOpICState::BinaryOpICState(Isolate* isolate, ExtraICState extra_ic_state) |
48 : fixed_right_arg_( | 48 : fixed_right_arg_( |
49 HasFixedRightArgField::decode(extra_ic_state) | 49 HasFixedRightArgField::decode(extra_ic_state) |
50 ? Just(1 << FixedRightArgValueField::decode(extra_ic_state)) | 50 ? Just(1 << FixedRightArgValueField::decode(extra_ic_state)) |
51 : Nothing<int>()), | 51 : Nothing<int>()), |
52 isolate_(isolate) { | 52 isolate_(isolate) { |
53 op_ = | 53 op_ = |
54 static_cast<Token::Value>(FIRST_TOKEN + OpField::decode(extra_ic_state)); | 54 static_cast<Token::Value>(FIRST_TOKEN + OpField::decode(extra_ic_state)); |
55 strong_ = StrongField::decode(extra_ic_state); | 55 strong_ = StrengthField::decode(extra_ic_state); |
56 left_kind_ = LeftKindField::decode(extra_ic_state); | 56 left_kind_ = LeftKindField::decode(extra_ic_state); |
57 right_kind_ = fixed_right_arg_.IsJust() | 57 right_kind_ = fixed_right_arg_.IsJust() |
58 ? (Smi::IsValid(fixed_right_arg_.FromJust()) ? SMI : INT32) | 58 ? (Smi::IsValid(fixed_right_arg_.FromJust()) ? SMI : INT32) |
59 : RightKindField::decode(extra_ic_state); | 59 : RightKindField::decode(extra_ic_state); |
60 result_kind_ = ResultKindField::decode(extra_ic_state); | 60 result_kind_ = ResultKindField::decode(extra_ic_state); |
61 DCHECK_LE(FIRST_TOKEN, op_); | 61 DCHECK_LE(FIRST_TOKEN, op_); |
62 DCHECK_LE(op_, LAST_TOKEN); | 62 DCHECK_LE(op_, LAST_TOKEN); |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 ExtraICState BinaryOpICState::GetExtraICState() const { | 66 ExtraICState BinaryOpICState::GetExtraICState() const { |
67 ExtraICState extra_ic_state = | 67 ExtraICState extra_ic_state = |
68 OpField::encode(op_ - FIRST_TOKEN) | LeftKindField::encode(left_kind_) | | 68 OpField::encode(op_ - FIRST_TOKEN) | LeftKindField::encode(left_kind_) | |
69 ResultKindField::encode(result_kind_) | | 69 ResultKindField::encode(result_kind_) | StrengthField::encode(strong_) | |
70 StrongField::encode(strong_) | | |
71 HasFixedRightArgField::encode(fixed_right_arg_.IsJust()); | 70 HasFixedRightArgField::encode(fixed_right_arg_.IsJust()); |
72 if (fixed_right_arg_.IsJust()) { | 71 if (fixed_right_arg_.IsJust()) { |
73 extra_ic_state = FixedRightArgValueField::update( | 72 extra_ic_state = FixedRightArgValueField::update( |
74 extra_ic_state, WhichPowerOf2(fixed_right_arg_.FromJust())); | 73 extra_ic_state, WhichPowerOf2(fixed_right_arg_.FromJust())); |
75 } else { | 74 } else { |
76 extra_ic_state = RightKindField::update(extra_ic_state, right_kind_); | 75 extra_ic_state = RightKindField::update(extra_ic_state, right_kind_); |
77 } | 76 } |
78 return extra_ic_state; | 77 return extra_ic_state; |
79 } | 78 } |
80 | 79 |
81 | 80 |
82 // static | 81 // static |
83 void BinaryOpICState::GenerateAheadOfTime( | 82 void BinaryOpICState::GenerateAheadOfTime( |
84 Isolate* isolate, void (*Generate)(Isolate*, const BinaryOpICState&)) { | 83 Isolate* isolate, void (*Generate)(Isolate*, const BinaryOpICState&)) { |
85 // TODO(olivf) We should investigate why adding stubs to the snapshot is so | 84 // TODO(olivf) We should investigate why adding stubs to the snapshot is so |
86 // expensive at runtime. When solved we should be able to add most binops to | 85 // expensive at runtime. When solved we should be able to add most binops to |
87 // the snapshot instead of hand-picking them. | 86 // the snapshot instead of hand-picking them. |
88 // Generated list of commonly used stubs | 87 // Generated list of commonly used stubs |
89 #define GENERATE(op, left_kind, right_kind, result_kind) \ | 88 #define GENERATE(op, left_kind, right_kind, result_kind) \ |
90 do { \ | 89 do { \ |
91 BinaryOpICState state(isolate, op, LanguageMode::SLOPPY); \ | 90 BinaryOpICState state(isolate, op, Strength::WEAK); \ |
92 state.left_kind_ = left_kind; \ | 91 state.left_kind_ = left_kind; \ |
93 state.fixed_right_arg_ = Nothing<int>(); \ | 92 state.fixed_right_arg_ = Nothing<int>(); \ |
94 state.right_kind_ = right_kind; \ | 93 state.right_kind_ = right_kind; \ |
95 state.result_kind_ = result_kind; \ | 94 state.result_kind_ = result_kind; \ |
96 Generate(isolate, state); \ | 95 Generate(isolate, state); \ |
97 } while (false) | 96 } while (false) |
98 GENERATE(Token::ADD, INT32, INT32, INT32); | 97 GENERATE(Token::ADD, INT32, INT32, INT32); |
99 GENERATE(Token::ADD, INT32, INT32, NUMBER); | 98 GENERATE(Token::ADD, INT32, INT32, NUMBER); |
100 GENERATE(Token::ADD, INT32, NUMBER, NUMBER); | 99 GENERATE(Token::ADD, INT32, NUMBER, NUMBER); |
101 GENERATE(Token::ADD, INT32, SMI, INT32); | 100 GENERATE(Token::ADD, INT32, SMI, INT32); |
102 GENERATE(Token::ADD, NUMBER, INT32, NUMBER); | 101 GENERATE(Token::ADD, NUMBER, INT32, NUMBER); |
103 GENERATE(Token::ADD, NUMBER, NUMBER, NUMBER); | 102 GENERATE(Token::ADD, NUMBER, NUMBER, NUMBER); |
104 GENERATE(Token::ADD, NUMBER, SMI, NUMBER); | 103 GENERATE(Token::ADD, NUMBER, SMI, NUMBER); |
105 GENERATE(Token::ADD, SMI, INT32, INT32); | 104 GENERATE(Token::ADD, SMI, INT32, INT32); |
106 GENERATE(Token::ADD, SMI, INT32, NUMBER); | 105 GENERATE(Token::ADD, SMI, INT32, NUMBER); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 GENERATE(Token::SUB, INT32, SMI, INT32); | 182 GENERATE(Token::SUB, INT32, SMI, INT32); |
184 GENERATE(Token::SUB, NUMBER, INT32, NUMBER); | 183 GENERATE(Token::SUB, NUMBER, INT32, NUMBER); |
185 GENERATE(Token::SUB, NUMBER, NUMBER, NUMBER); | 184 GENERATE(Token::SUB, NUMBER, NUMBER, NUMBER); |
186 GENERATE(Token::SUB, NUMBER, SMI, NUMBER); | 185 GENERATE(Token::SUB, NUMBER, SMI, NUMBER); |
187 GENERATE(Token::SUB, SMI, INT32, INT32); | 186 GENERATE(Token::SUB, SMI, INT32, INT32); |
188 GENERATE(Token::SUB, SMI, NUMBER, NUMBER); | 187 GENERATE(Token::SUB, SMI, NUMBER, NUMBER); |
189 GENERATE(Token::SUB, SMI, SMI, SMI); | 188 GENERATE(Token::SUB, SMI, SMI, SMI); |
190 #undef GENERATE | 189 #undef GENERATE |
191 #define GENERATE(op, left_kind, fixed_right_arg_value, result_kind) \ | 190 #define GENERATE(op, left_kind, fixed_right_arg_value, result_kind) \ |
192 do { \ | 191 do { \ |
193 BinaryOpICState state(isolate, op, LanguageMode::SLOPPY); \ | 192 BinaryOpICState state(isolate, op, Strength::WEAK); \ |
194 state.left_kind_ = left_kind; \ | 193 state.left_kind_ = left_kind; \ |
195 state.fixed_right_arg_ = Just(fixed_right_arg_value); \ | 194 state.fixed_right_arg_ = Just(fixed_right_arg_value); \ |
196 state.right_kind_ = SMI; \ | 195 state.right_kind_ = SMI; \ |
197 state.result_kind_ = result_kind; \ | 196 state.result_kind_ = result_kind; \ |
198 Generate(isolate, state); \ | 197 Generate(isolate, state); \ |
199 } while (false) | 198 } while (false) |
200 GENERATE(Token::MOD, SMI, 2, SMI); | 199 GENERATE(Token::MOD, SMI, 2, SMI); |
201 GENERATE(Token::MOD, SMI, 4, SMI); | 200 GENERATE(Token::MOD, SMI, 4, SMI); |
202 GENERATE(Token::MOD, SMI, 8, SMI); | 201 GENERATE(Token::MOD, SMI, 8, SMI); |
203 GENERATE(Token::MOD, SMI, 16, SMI); | 202 GENERATE(Token::MOD, SMI, 16, SMI); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 case UNIQUE_NAME: | 505 case UNIQUE_NAME: |
507 case OBJECT: | 506 case OBJECT: |
508 case GENERIC: | 507 case GENERIC: |
509 return GENERIC; | 508 return GENERIC; |
510 } | 509 } |
511 UNREACHABLE(); | 510 UNREACHABLE(); |
512 return GENERIC; // Make the compiler happy. | 511 return GENERIC; // Make the compiler happy. |
513 } | 512 } |
514 } // namespace internal | 513 } // namespace internal |
515 } // namespace v8 | 514 } // namespace v8 |
OLD | NEW |