OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/double.h" | 8 #include "src/double.h" |
9 #include "src/elements.h" | 9 #include "src/elements.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 3189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3200 } | 3200 } |
3201 if (access().IsStringLength()) { | 3201 if (access().IsStringLength()) { |
3202 return new(zone) Range(0, String::kMaxLength); | 3202 return new(zone) Range(0, String::kMaxLength); |
3203 } | 3203 } |
3204 return HValue::InferRange(zone); | 3204 return HValue::InferRange(zone); |
3205 } | 3205 } |
3206 | 3206 |
3207 | 3207 |
3208 Range* HLoadKeyed::InferRange(Zone* zone) { | 3208 Range* HLoadKeyed::InferRange(Zone* zone) { |
3209 switch (elements_kind()) { | 3209 switch (elements_kind()) { |
3210 case EXTERNAL_INT8_ELEMENTS: | |
3211 case INT8_ELEMENTS: | 3210 case INT8_ELEMENTS: |
3212 return new(zone) Range(kMinInt8, kMaxInt8); | 3211 return new(zone) Range(kMinInt8, kMaxInt8); |
3213 case EXTERNAL_UINT8_ELEMENTS: | |
3214 case EXTERNAL_UINT8_CLAMPED_ELEMENTS: | |
3215 case UINT8_ELEMENTS: | 3212 case UINT8_ELEMENTS: |
3216 case UINT8_CLAMPED_ELEMENTS: | 3213 case UINT8_CLAMPED_ELEMENTS: |
3217 return new(zone) Range(kMinUInt8, kMaxUInt8); | 3214 return new(zone) Range(kMinUInt8, kMaxUInt8); |
3218 case EXTERNAL_INT16_ELEMENTS: | |
3219 case INT16_ELEMENTS: | 3215 case INT16_ELEMENTS: |
3220 return new(zone) Range(kMinInt16, kMaxInt16); | 3216 return new(zone) Range(kMinInt16, kMaxInt16); |
3221 case EXTERNAL_UINT16_ELEMENTS: | |
3222 case UINT16_ELEMENTS: | 3217 case UINT16_ELEMENTS: |
3223 return new(zone) Range(kMinUInt16, kMaxUInt16); | 3218 return new(zone) Range(kMinUInt16, kMaxUInt16); |
3224 default: | 3219 default: |
3225 return HValue::InferRange(zone); | 3220 return HValue::InferRange(zone); |
3226 } | 3221 } |
3227 } | 3222 } |
3228 | 3223 |
3229 | 3224 |
3230 std::ostream& HCompareGeneric::PrintDataTo(std::ostream& os) const { // NOLINT | 3225 std::ostream& HCompareGeneric::PrintDataTo(std::ostream& os) const { // NOLINT |
3231 os << Token::Name(token()) << " "; | 3226 os << Token::Name(token()) << " "; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3454 | 3449 |
3455 | 3450 |
3456 std::ostream& HLoadNamedGeneric::PrintDataTo( | 3451 std::ostream& HLoadNamedGeneric::PrintDataTo( |
3457 std::ostream& os) const { // NOLINT | 3452 std::ostream& os) const { // NOLINT |
3458 Handle<String> n = Handle<String>::cast(name()); | 3453 Handle<String> n = Handle<String>::cast(name()); |
3459 return os << NameOf(object()) << "." << n->ToCString().get(); | 3454 return os << NameOf(object()) << "." << n->ToCString().get(); |
3460 } | 3455 } |
3461 | 3456 |
3462 | 3457 |
3463 std::ostream& HLoadKeyed::PrintDataTo(std::ostream& os) const { // NOLINT | 3458 std::ostream& HLoadKeyed::PrintDataTo(std::ostream& os) const { // NOLINT |
3464 if (!is_external()) { | 3459 if (!is_fixed_typed_array()) { |
3465 os << NameOf(elements()); | 3460 os << NameOf(elements()); |
3466 } else { | 3461 } else { |
3467 DCHECK(elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && | 3462 DCHECK(elements_kind() >= FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND && |
3468 elements_kind() <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 3463 elements_kind() <= LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND); |
3469 os << NameOf(elements()) << "." << ElementsKindToString(elements_kind()); | 3464 os << NameOf(elements()) << "." << ElementsKindToString(elements_kind()); |
3470 } | 3465 } |
3471 | 3466 |
3472 os << "[" << NameOf(key()); | 3467 os << "[" << NameOf(key()); |
3473 if (IsDehoisted()) os << " + " << base_offset(); | 3468 if (IsDehoisted()) os << " + " << base_offset(); |
3474 os << "]"; | 3469 os << "]"; |
3475 | 3470 |
3476 if (HasDependency()) os << " " << NameOf(dependency()); | 3471 if (HasDependency()) os << " " << NameOf(dependency()); |
3477 if (RequiresHoleCheck()) os << " check_hole"; | 3472 if (RequiresHoleCheck()) os << " check_hole"; |
3478 return os; | 3473 return os; |
(...skipping 14 matching lines...) Expand all Loading... |
3493 bit_field_ = BaseOffsetField::update(bit_field_, base_offset); | 3488 bit_field_ = BaseOffsetField::update(bit_field_, base_offset); |
3494 return true; | 3489 return true; |
3495 } | 3490 } |
3496 | 3491 |
3497 | 3492 |
3498 bool HLoadKeyed::UsesMustHandleHole() const { | 3493 bool HLoadKeyed::UsesMustHandleHole() const { |
3499 if (IsFastPackedElementsKind(elements_kind())) { | 3494 if (IsFastPackedElementsKind(elements_kind())) { |
3500 return false; | 3495 return false; |
3501 } | 3496 } |
3502 | 3497 |
3503 if (IsExternalArrayElementsKind(elements_kind())) { | 3498 if (IsFixedTypedArrayElementsKind(elements_kind())) { |
3504 return false; | 3499 return false; |
3505 } | 3500 } |
3506 | 3501 |
3507 if (hole_mode() == ALLOW_RETURN_HOLE) { | 3502 if (hole_mode() == ALLOW_RETURN_HOLE) { |
3508 if (IsFastDoubleElementsKind(elements_kind())) { | 3503 if (IsFastDoubleElementsKind(elements_kind())) { |
3509 return AllUsesCanTreatHoleAsNaN(); | 3504 return AllUsesCanTreatHoleAsNaN(); |
3510 } | 3505 } |
3511 return true; | 3506 return true; |
3512 } | 3507 } |
3513 | 3508 |
(...skipping 19 matching lines...) Expand all Loading... |
3533 return IsFastDoubleElementsKind(elements_kind()) && | 3528 return IsFastDoubleElementsKind(elements_kind()) && |
3534 CheckUsesForFlag(HValue::kAllowUndefinedAsNaN); | 3529 CheckUsesForFlag(HValue::kAllowUndefinedAsNaN); |
3535 } | 3530 } |
3536 | 3531 |
3537 | 3532 |
3538 bool HLoadKeyed::RequiresHoleCheck() const { | 3533 bool HLoadKeyed::RequiresHoleCheck() const { |
3539 if (IsFastPackedElementsKind(elements_kind())) { | 3534 if (IsFastPackedElementsKind(elements_kind())) { |
3540 return false; | 3535 return false; |
3541 } | 3536 } |
3542 | 3537 |
3543 if (IsExternalArrayElementsKind(elements_kind())) { | 3538 if (IsFixedTypedArrayElementsKind(elements_kind())) { |
3544 return false; | 3539 return false; |
3545 } | 3540 } |
3546 | 3541 |
3547 if (hole_mode() == CONVERT_HOLE_TO_UNDEFINED) { | 3542 if (hole_mode() == CONVERT_HOLE_TO_UNDEFINED) { |
3548 return false; | 3543 return false; |
3549 } | 3544 } |
3550 | 3545 |
3551 return !UsesMustHandleHole(); | 3546 return !UsesMustHandleHole(); |
3552 } | 3547 } |
3553 | 3548 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3608 | 3603 |
3609 std::ostream& HStoreNamedField::PrintDataTo(std::ostream& os) const { // NOLINT | 3604 std::ostream& HStoreNamedField::PrintDataTo(std::ostream& os) const { // NOLINT |
3610 os << NameOf(object()) << access_ << " = " << NameOf(value()); | 3605 os << NameOf(object()) << access_ << " = " << NameOf(value()); |
3611 if (NeedsWriteBarrier()) os << " (write-barrier)"; | 3606 if (NeedsWriteBarrier()) os << " (write-barrier)"; |
3612 if (has_transition()) os << " (transition map " << *transition_map() << ")"; | 3607 if (has_transition()) os << " (transition map " << *transition_map() << ")"; |
3613 return os; | 3608 return os; |
3614 } | 3609 } |
3615 | 3610 |
3616 | 3611 |
3617 std::ostream& HStoreKeyed::PrintDataTo(std::ostream& os) const { // NOLINT | 3612 std::ostream& HStoreKeyed::PrintDataTo(std::ostream& os) const { // NOLINT |
3618 if (!is_external()) { | 3613 if (!is_fixed_typed_array()) { |
3619 os << NameOf(elements()); | 3614 os << NameOf(elements()); |
3620 } else { | 3615 } else { |
3621 DCHECK(elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && | 3616 DCHECK(elements_kind() >= FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND && |
3622 elements_kind() <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 3617 elements_kind() <= LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND); |
3623 os << NameOf(elements()) << "." << ElementsKindToString(elements_kind()); | 3618 os << NameOf(elements()) << "." << ElementsKindToString(elements_kind()); |
3624 } | 3619 } |
3625 | 3620 |
3626 os << "[" << NameOf(key()); | 3621 os << "[" << NameOf(key()); |
3627 if (IsDehoisted()) os << " + " << base_offset(); | 3622 if (IsDehoisted()) os << " + " << base_offset(); |
3628 return os << "] = " << NameOf(value()); | 3623 return os << "] = " << NameOf(value()); |
3629 } | 3624 } |
3630 | 3625 |
3631 | 3626 |
3632 std::ostream& HStoreKeyedGeneric::PrintDataTo( | 3627 std::ostream& HStoreKeyedGeneric::PrintDataTo( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3976 if (!addition_result.IsValid()) return false; | 3971 if (!addition_result.IsValid()) return false; |
3977 base_offset_ = addition_result.ValueOrDie(); | 3972 base_offset_ = addition_result.ValueOrDie(); |
3978 return true; | 3973 return true; |
3979 } | 3974 } |
3980 | 3975 |
3981 | 3976 |
3982 bool HStoreKeyed::NeedsCanonicalization() { | 3977 bool HStoreKeyed::NeedsCanonicalization() { |
3983 switch (value()->opcode()) { | 3978 switch (value()->opcode()) { |
3984 case kLoadKeyed: { | 3979 case kLoadKeyed: { |
3985 ElementsKind load_kind = HLoadKeyed::cast(value())->elements_kind(); | 3980 ElementsKind load_kind = HLoadKeyed::cast(value())->elements_kind(); |
3986 return IsExternalFloatOrDoubleElementsKind(load_kind) || | 3981 return IsFixedFloatElementsKind(load_kind); |
3987 IsFixedFloatElementsKind(load_kind); | |
3988 } | 3982 } |
3989 case kChange: { | 3983 case kChange: { |
3990 Representation from = HChange::cast(value())->from(); | 3984 Representation from = HChange::cast(value())->from(); |
3991 return from.IsTagged() || from.IsHeapObject(); | 3985 return from.IsTagged() || from.IsHeapObject(); |
3992 } | 3986 } |
3993 case kLoadNamedField: | 3987 case kLoadNamedField: |
3994 case kPhi: { | 3988 case kPhi: { |
3995 // Better safe than sorry... | 3989 // Better safe than sorry... |
3996 return true; | 3990 return true; |
3997 } | 3991 } |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4742 case HObjectAccess::kExternalMemory: | 4736 case HObjectAccess::kExternalMemory: |
4743 os << "[external-memory]"; | 4737 os << "[external-memory]"; |
4744 break; | 4738 break; |
4745 } | 4739 } |
4746 | 4740 |
4747 return os << "@" << access.offset(); | 4741 return os << "@" << access.offset(); |
4748 } | 4742 } |
4749 | 4743 |
4750 } // namespace internal | 4744 } // namespace internal |
4751 } // namespace v8 | 4745 } // namespace v8 |
OLD | NEW |