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/hydrogen-instructions.h" | 5 #include "src/hydrogen-instructions.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 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1298 } | 1298 } |
1299 | 1299 |
1300 | 1300 |
1301 std::ostream& HTypeofIsAndBranch::PrintDataTo( | 1301 std::ostream& HTypeofIsAndBranch::PrintDataTo( |
1302 std::ostream& os) const { // NOLINT | 1302 std::ostream& os) const { // NOLINT |
1303 os << NameOf(value()) << " == " << type_literal()->ToCString().get(); | 1303 os << NameOf(value()) << " == " << type_literal()->ToCString().get(); |
1304 return HControlInstruction::PrintDataTo(os); | 1304 return HControlInstruction::PrintDataTo(os); |
1305 } | 1305 } |
1306 | 1306 |
1307 | 1307 |
1308 static String* TypeOfString(HConstant* constant, Isolate* isolate) { | 1308 namespace { |
1309 | |
1310 String* TypeOfString(HConstant* constant, Isolate* isolate) { | |
1309 Heap* heap = isolate->heap(); | 1311 Heap* heap = isolate->heap(); |
1310 if (constant->HasNumberValue()) return heap->number_string(); | 1312 if (constant->HasNumberValue()) return heap->number_string(); |
1311 if (constant->IsUndetectable()) return heap->undefined_string(); | 1313 if (constant->IsUndetectable()) return heap->undefined_string(); |
1312 if (constant->HasStringValue()) return heap->string_string(); | 1314 if (constant->HasStringValue()) return heap->string_string(); |
1313 switch (constant->GetInstanceType()) { | 1315 switch (constant->GetInstanceType()) { |
1314 case ODDBALL_TYPE: { | 1316 case ODDBALL_TYPE: { |
1315 Unique<Object> unique = constant->GetUnique(); | 1317 Unique<Object> unique = constant->GetUnique(); |
1316 if (unique.IsKnownGlobal(heap->true_value()) || | 1318 if (unique.IsKnownGlobal(heap->true_value()) || |
1317 unique.IsKnownGlobal(heap->false_value())) { | 1319 unique.IsKnownGlobal(heap->false_value())) { |
1318 return heap->boolean_string(); | 1320 return heap->boolean_string(); |
(...skipping 10 matching lines...) Expand all Loading... | |
1329 Unique<Map> map = constant->ObjectMap(); | 1331 Unique<Map> map = constant->ObjectMap(); |
1330 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ | 1332 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ |
1331 if (map.IsKnownGlobal(heap->type##_map())) { \ | 1333 if (map.IsKnownGlobal(heap->type##_map())) { \ |
1332 return heap->type##_string(); \ | 1334 return heap->type##_string(); \ |
1333 } | 1335 } |
1334 SIMD128_TYPES(SIMD128_TYPE) | 1336 SIMD128_TYPES(SIMD128_TYPE) |
1335 #undef SIMD128_TYPE | 1337 #undef SIMD128_TYPE |
1336 UNREACHABLE(); | 1338 UNREACHABLE(); |
1337 return nullptr; | 1339 return nullptr; |
1338 } | 1340 } |
1339 case JS_FUNCTION_TYPE: | |
1340 case JS_FUNCTION_PROXY_TYPE: | |
1341 return heap->function_string(); | |
1342 default: | 1341 default: |
1342 if (constant->IsCallable()) return heap->function_string(); | |
1343 return heap->object_string(); | 1343 return heap->object_string(); |
1344 } | 1344 } |
1345 } | 1345 } |
1346 | 1346 |
1347 } // namespace | |
1348 | |
1347 | 1349 |
1348 bool HTypeofIsAndBranch::KnownSuccessorBlock(HBasicBlock** block) { | 1350 bool HTypeofIsAndBranch::KnownSuccessorBlock(HBasicBlock** block) { |
1349 if (FLAG_fold_constants && value()->IsConstant()) { | 1351 if (FLAG_fold_constants && value()->IsConstant()) { |
1350 HConstant* constant = HConstant::cast(value()); | 1352 HConstant* constant = HConstant::cast(value()); |
1351 String* type_string = TypeOfString(constant, isolate()); | 1353 String* type_string = TypeOfString(constant, isolate()); |
1352 bool same_type = type_literal_.IsKnownGlobal(type_string); | 1354 bool same_type = type_literal_.IsKnownGlobal(type_string); |
1353 *block = same_type ? FirstSuccessor() : SecondSuccessor(); | 1355 *block = same_type ? FirstSuccessor() : SecondSuccessor(); |
1354 return true; | 1356 return true; |
1355 } else if (value()->representation().IsSpecialization()) { | 1357 } else if (value()->representation().IsSpecialization()) { |
1356 bool number_type = | 1358 bool number_type = |
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2710 DCHECK_EQ(kHoleNaN, special); | 2712 DCHECK_EQ(kHoleNaN, special); |
2711 std::memcpy(&double_value_, &kHoleNanInt64, sizeof(double_value_)); | 2713 std::memcpy(&double_value_, &kHoleNanInt64, sizeof(double_value_)); |
2712 Initialize(Representation::Double()); | 2714 Initialize(Representation::Double()); |
2713 } | 2715 } |
2714 | 2716 |
2715 | 2717 |
2716 HConstant::HConstant(Handle<Object> object, Representation r) | 2718 HConstant::HConstant(Handle<Object> object, Representation r) |
2717 : HTemplateInstruction<0>(HType::FromValue(object)), | 2719 : HTemplateInstruction<0>(HType::FromValue(object)), |
2718 object_(Unique<Object>::CreateUninitialized(object)), | 2720 object_(Unique<Object>::CreateUninitialized(object)), |
2719 object_map_(Handle<Map>::null()), | 2721 object_map_(Handle<Map>::null()), |
2720 bit_field_(HasStableMapValueField::encode(false) | | 2722 bit_field_( |
2721 HasSmiValueField::encode(false) | | 2723 HasStableMapValueField::encode(false) | |
2722 HasInt32ValueField::encode(false) | | 2724 HasSmiValueField::encode(false) | HasInt32ValueField::encode(false) | |
2723 HasDoubleValueField::encode(false) | | 2725 HasDoubleValueField::encode(false) | |
2724 HasExternalReferenceValueField::encode(false) | | 2726 HasExternalReferenceValueField::encode(false) | |
2725 IsNotInNewSpaceField::encode(true) | | 2727 IsNotInNewSpaceField::encode(true) | |
2726 BooleanValueField::encode(object->BooleanValue()) | | 2728 BooleanValueField::encode(object->BooleanValue()) | |
2727 IsUndetectableField::encode(false) | | 2729 IsUndetectableField::encode(false) | IsCallableField::encode(false) | |
2728 InstanceTypeField::encode(kUnknownInstanceType)) { | 2730 InstanceTypeField::encode(kUnknownInstanceType)) { |
2729 if (object->IsHeapObject()) { | 2731 if (object->IsHeapObject()) { |
2730 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); | 2732 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); |
2731 Isolate* isolate = heap_object->GetIsolate(); | 2733 Isolate* isolate = heap_object->GetIsolate(); |
2732 Handle<Map> map(heap_object->map(), isolate); | 2734 Handle<Map> map(heap_object->map(), isolate); |
2733 bit_field_ = IsNotInNewSpaceField::update( | 2735 bit_field_ = IsNotInNewSpaceField::update( |
2734 bit_field_, !isolate->heap()->InNewSpace(*object)); | 2736 bit_field_, !isolate->heap()->InNewSpace(*object)); |
2735 bit_field_ = InstanceTypeField::update(bit_field_, map->instance_type()); | 2737 bit_field_ = InstanceTypeField::update(bit_field_, map->instance_type()); |
2736 bit_field_ = | 2738 bit_field_ = |
2737 IsUndetectableField::update(bit_field_, map->is_undetectable()); | 2739 IsUndetectableField::update(bit_field_, map->is_undetectable()); |
2740 bit_field_ = IsCallableField::update(bit_field_, map->is_callable()); | |
Yang
2015/08/27 08:39:18
Do we already use this field?
Benedikt Meurer
2015/08/27 08:39:54
Yep in TypeOfString in the .cc file.
| |
2738 if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map); | 2741 if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map); |
2739 bit_field_ = HasStableMapValueField::update( | 2742 bit_field_ = HasStableMapValueField::update( |
2740 bit_field_, | 2743 bit_field_, |
2741 HasMapValue() && Handle<Map>::cast(heap_object)->is_stable()); | 2744 HasMapValue() && Handle<Map>::cast(heap_object)->is_stable()); |
2742 } | 2745 } |
2743 if (object->IsNumber()) { | 2746 if (object->IsNumber()) { |
2744 double n = object->Number(); | 2747 double n = object->Number(); |
2745 bool has_int32_value = IsInteger32(n); | 2748 bool has_int32_value = IsInteger32(n); |
2746 bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value); | 2749 bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value); |
2747 int32_value_ = DoubleToInt32(n); | 2750 int32_value_ = DoubleToInt32(n); |
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4720 case HObjectAccess::kExternalMemory: | 4723 case HObjectAccess::kExternalMemory: |
4721 os << "[external-memory]"; | 4724 os << "[external-memory]"; |
4722 break; | 4725 break; |
4723 } | 4726 } |
4724 | 4727 |
4725 return os << "@" << access.offset(); | 4728 return os << "@" << access.offset(); |
4726 } | 4729 } |
4727 | 4730 |
4728 } // namespace internal | 4731 } // namespace internal |
4729 } // namespace v8 | 4732 } // namespace v8 |
OLD | NEW |