Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: src/ic/ic-state.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ic/ic-state.h ('k') | src/ic/mips/handler-compiler-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ic/ic-state.h" 5 #include "src/ic/ic-state.h"
6 6
7 #include "src/ic/ic.h" 7 #include "src/ic/ic.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 DCHECK_EQ(Token::ADD, op_); 250 DCHECK_EQ(Token::ADD, op_);
251 right_kind_ = NUMBER; 251 right_kind_ = NUMBER;
252 } else if (right_kind_ == STRING && left_kind_ == INT32) { 252 } else if (right_kind_ == STRING && left_kind_ == INT32) {
253 DCHECK_EQ(STRING, result_kind_); 253 DCHECK_EQ(STRING, result_kind_);
254 DCHECK_EQ(Token::ADD, op_); 254 DCHECK_EQ(Token::ADD, op_);
255 left_kind_ = NUMBER; 255 left_kind_ = NUMBER;
256 } 256 }
257 257
258 if (old_extra_ic_state == GetExtraICState()) { 258 if (old_extra_ic_state == GetExtraICState()) {
259 // Tagged operations can lead to non-truncating HChanges 259 // Tagged operations can lead to non-truncating HChanges
260 if (left->IsUndefined() || left->IsBoolean()) { 260 if (left->IsUndefined(isolate_) || left->IsBoolean()) {
261 left_kind_ = GENERIC; 261 left_kind_ = GENERIC;
262 } else { 262 } else {
263 DCHECK(right->IsUndefined() || right->IsBoolean()); 263 DCHECK(right->IsUndefined(isolate_) || right->IsBoolean());
264 right_kind_ = GENERIC; 264 right_kind_ = GENERIC;
265 } 265 }
266 } 266 }
267 } 267 }
268 268
269 269
270 BinaryOpICState::Kind BinaryOpICState::UpdateKind(Handle<Object> object, 270 BinaryOpICState::Kind BinaryOpICState::UpdateKind(Handle<Object> object,
271 Kind kind) const { 271 Kind kind) const {
272 Kind new_kind = GENERIC; 272 Kind new_kind = GENERIC;
273 bool is_truncating = Token::IsTruncatingBinaryOp(op()); 273 bool is_truncating = Token::IsTruncatingBinaryOp(op());
274 if (object->IsBoolean() && is_truncating) { 274 if (object->IsBoolean() && is_truncating) {
275 // Booleans will be automatically truncated by HChange. 275 // Booleans will be automatically truncated by HChange.
276 new_kind = INT32; 276 new_kind = INT32;
277 } else if (object->IsUndefined()) { 277 } else if (object->IsUndefined(isolate_)) {
278 // Undefined will be automatically truncated by HChange. 278 // Undefined will be automatically truncated by HChange.
279 new_kind = is_truncating ? INT32 : NUMBER; 279 new_kind = is_truncating ? INT32 : NUMBER;
280 } else if (object->IsSmi()) { 280 } else if (object->IsSmi()) {
281 new_kind = SMI; 281 new_kind = SMI;
282 } else if (object->IsHeapNumber()) { 282 } else if (object->IsHeapNumber()) {
283 double value = Handle<HeapNumber>::cast(object)->value(); 283 double value = Handle<HeapNumber>::cast(object)->value();
284 new_kind = IsInt32Double(value) ? INT32 : NUMBER; 284 new_kind = IsInt32Double(value) ? INT32 : NUMBER;
285 } else if (object->IsString() && op() == Token::ADD) { 285 } else if (object->IsString() && op() == Token::ADD) {
286 new_kind = STRING; 286 new_kind = STRING;
287 } 287 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 case KNOWN_RECEIVER: 439 case KNOWN_RECEIVER:
440 UNREACHABLE(); 440 UNREACHABLE();
441 break; 441 break;
442 } 442 }
443 return GENERIC; 443 return GENERIC;
444 } 444 }
445 445
446 446
447 // static 447 // static
448 CompareICState::State CompareICState::TargetState( 448 CompareICState::State CompareICState::TargetState(
449 State old_state, State old_left, State old_right, Token::Value op, 449 Isolate* isolate, State old_state, State old_left, State old_right,
450 bool has_inlined_smi_code, Handle<Object> x, Handle<Object> y) { 450 Token::Value op, bool has_inlined_smi_code, Handle<Object> x,
451 Handle<Object> y) {
451 switch (old_state) { 452 switch (old_state) {
452 case UNINITIALIZED: 453 case UNINITIALIZED:
453 if (x->IsBoolean() && y->IsBoolean()) return BOOLEAN; 454 if (x->IsBoolean() && y->IsBoolean()) return BOOLEAN;
454 if (x->IsSmi() && y->IsSmi()) return SMI; 455 if (x->IsSmi() && y->IsSmi()) return SMI;
455 if (x->IsNumber() && y->IsNumber()) return NUMBER; 456 if (x->IsNumber() && y->IsNumber()) return NUMBER;
456 if (Token::IsOrderedRelationalCompareOp(op)) { 457 if (Token::IsOrderedRelationalCompareOp(op)) {
457 // Ordered comparisons treat undefined as NaN, so the 458 // Ordered comparisons treat undefined as NaN, so the
458 // NUMBER stub will do the right thing. 459 // NUMBER stub will do the right thing.
459 if ((x->IsNumber() && y->IsUndefined()) || 460 if ((x->IsNumber() && y->IsUndefined(isolate)) ||
460 (y->IsNumber() && x->IsUndefined())) { 461 (y->IsNumber() && x->IsUndefined(isolate))) {
461 return NUMBER; 462 return NUMBER;
462 } 463 }
463 } 464 }
464 if (x->IsInternalizedString() && y->IsInternalizedString()) { 465 if (x->IsInternalizedString() && y->IsInternalizedString()) {
465 // We compare internalized strings as plain ones if we need to determine 466 // We compare internalized strings as plain ones if we need to determine
466 // the order in a non-equality compare. 467 // the order in a non-equality compare.
467 return Token::IsEqualityOp(op) ? INTERNALIZED_STRING : STRING; 468 return Token::IsEqualityOp(op) ? INTERNALIZED_STRING : STRING;
468 } 469 }
469 if (x->IsString() && y->IsString()) return STRING; 470 if (x->IsString() && y->IsString()) return STRING;
470 if (x->IsJSReceiver() && y->IsJSReceiver()) { 471 if (x->IsJSReceiver() && y->IsJSReceiver()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 case RECEIVER: 507 case RECEIVER:
507 case GENERIC: 508 case GENERIC:
508 return GENERIC; 509 return GENERIC;
509 } 510 }
510 UNREACHABLE(); 511 UNREACHABLE();
511 return GENERIC; // Make the compiler happy. 512 return GENERIC; // Make the compiler happy.
512 } 513 }
513 514
514 } // namespace internal 515 } // namespace internal
515 } // namespace v8 516 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ic-state.h ('k') | src/ic/mips/handler-compiler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698