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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 } | 1292 } |
1293 | 1293 |
1294 | 1294 |
1295 std::ostream& HTypeofIsAndBranch::PrintDataTo( | 1295 std::ostream& HTypeofIsAndBranch::PrintDataTo( |
1296 std::ostream& os) const { // NOLINT | 1296 std::ostream& os) const { // NOLINT |
1297 os << NameOf(value()) << " == " << type_literal()->ToCString().get(); | 1297 os << NameOf(value()) << " == " << type_literal()->ToCString().get(); |
1298 return HControlInstruction::PrintDataTo(os); | 1298 return HControlInstruction::PrintDataTo(os); |
1299 } | 1299 } |
1300 | 1300 |
1301 | 1301 |
1302 static String* TypeOfString(HConstant* constant, Isolate* isolate) { | 1302 namespace { |
| 1303 |
| 1304 String* TypeOfString(HConstant* constant, Isolate* isolate) { |
1303 Heap* heap = isolate->heap(); | 1305 Heap* heap = isolate->heap(); |
1304 if (constant->HasNumberValue()) return heap->number_string(); | 1306 if (constant->HasNumberValue()) return heap->number_string(); |
1305 if (constant->IsUndetectable()) return heap->undefined_string(); | 1307 if (constant->IsUndetectable()) return heap->undefined_string(); |
1306 if (constant->HasStringValue()) return heap->string_string(); | 1308 if (constant->HasStringValue()) return heap->string_string(); |
1307 switch (constant->GetInstanceType()) { | 1309 switch (constant->GetInstanceType()) { |
1308 case ODDBALL_TYPE: { | 1310 case ODDBALL_TYPE: { |
1309 Unique<Object> unique = constant->GetUnique(); | 1311 Unique<Object> unique = constant->GetUnique(); |
1310 if (unique.IsKnownGlobal(heap->true_value()) || | 1312 if (unique.IsKnownGlobal(heap->true_value()) || |
1311 unique.IsKnownGlobal(heap->false_value())) { | 1313 unique.IsKnownGlobal(heap->false_value())) { |
1312 return heap->boolean_string(); | 1314 return heap->boolean_string(); |
(...skipping 10 matching lines...) Expand all Loading... |
1323 Unique<Map> map = constant->ObjectMap(); | 1325 Unique<Map> map = constant->ObjectMap(); |
1324 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ | 1326 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ |
1325 if (map.IsKnownGlobal(heap->type##_map())) { \ | 1327 if (map.IsKnownGlobal(heap->type##_map())) { \ |
1326 return heap->type##_string(); \ | 1328 return heap->type##_string(); \ |
1327 } | 1329 } |
1328 SIMD128_TYPES(SIMD128_TYPE) | 1330 SIMD128_TYPES(SIMD128_TYPE) |
1329 #undef SIMD128_TYPE | 1331 #undef SIMD128_TYPE |
1330 UNREACHABLE(); | 1332 UNREACHABLE(); |
1331 return nullptr; | 1333 return nullptr; |
1332 } | 1334 } |
1333 case JS_FUNCTION_TYPE: | |
1334 case JS_FUNCTION_PROXY_TYPE: | |
1335 return heap->function_string(); | |
1336 default: | 1335 default: |
| 1336 if (constant->IsCallable()) return heap->function_string(); |
1337 return heap->object_string(); | 1337 return heap->object_string(); |
1338 } | 1338 } |
1339 } | 1339 } |
1340 | 1340 |
| 1341 } // namespace |
| 1342 |
1341 | 1343 |
1342 bool HTypeofIsAndBranch::KnownSuccessorBlock(HBasicBlock** block) { | 1344 bool HTypeofIsAndBranch::KnownSuccessorBlock(HBasicBlock** block) { |
1343 if (FLAG_fold_constants && value()->IsConstant()) { | 1345 if (FLAG_fold_constants && value()->IsConstant()) { |
1344 HConstant* constant = HConstant::cast(value()); | 1346 HConstant* constant = HConstant::cast(value()); |
1345 String* type_string = TypeOfString(constant, isolate()); | 1347 String* type_string = TypeOfString(constant, isolate()); |
1346 bool same_type = type_literal_.IsKnownGlobal(type_string); | 1348 bool same_type = type_literal_.IsKnownGlobal(type_string); |
1347 *block = same_type ? FirstSuccessor() : SecondSuccessor(); | 1349 *block = same_type ? FirstSuccessor() : SecondSuccessor(); |
1348 return true; | 1350 return true; |
1349 } else if (value()->representation().IsSpecialization()) { | 1351 } else if (value()->representation().IsSpecialization()) { |
1350 bool number_type = | 1352 bool number_type = |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2698 DCHECK_EQ(kHoleNaN, special); | 2700 DCHECK_EQ(kHoleNaN, special); |
2699 std::memcpy(&double_value_, &kHoleNanInt64, sizeof(double_value_)); | 2701 std::memcpy(&double_value_, &kHoleNanInt64, sizeof(double_value_)); |
2700 Initialize(Representation::Double()); | 2702 Initialize(Representation::Double()); |
2701 } | 2703 } |
2702 | 2704 |
2703 | 2705 |
2704 HConstant::HConstant(Handle<Object> object, Representation r) | 2706 HConstant::HConstant(Handle<Object> object, Representation r) |
2705 : HTemplateInstruction<0>(HType::FromValue(object)), | 2707 : HTemplateInstruction<0>(HType::FromValue(object)), |
2706 object_(Unique<Object>::CreateUninitialized(object)), | 2708 object_(Unique<Object>::CreateUninitialized(object)), |
2707 object_map_(Handle<Map>::null()), | 2709 object_map_(Handle<Map>::null()), |
2708 bit_field_(HasStableMapValueField::encode(false) | | 2710 bit_field_( |
2709 HasSmiValueField::encode(false) | | 2711 HasStableMapValueField::encode(false) | |
2710 HasInt32ValueField::encode(false) | | 2712 HasSmiValueField::encode(false) | HasInt32ValueField::encode(false) | |
2711 HasDoubleValueField::encode(false) | | 2713 HasDoubleValueField::encode(false) | |
2712 HasExternalReferenceValueField::encode(false) | | 2714 HasExternalReferenceValueField::encode(false) | |
2713 IsNotInNewSpaceField::encode(true) | | 2715 IsNotInNewSpaceField::encode(true) | |
2714 BooleanValueField::encode(object->BooleanValue()) | | 2716 BooleanValueField::encode(object->BooleanValue()) | |
2715 IsUndetectableField::encode(false) | | 2717 IsUndetectableField::encode(false) | IsCallableField::encode(false) | |
2716 InstanceTypeField::encode(kUnknownInstanceType)) { | 2718 InstanceTypeField::encode(kUnknownInstanceType)) { |
2717 if (object->IsHeapObject()) { | 2719 if (object->IsHeapObject()) { |
2718 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); | 2720 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); |
2719 Isolate* isolate = heap_object->GetIsolate(); | 2721 Isolate* isolate = heap_object->GetIsolate(); |
2720 Handle<Map> map(heap_object->map(), isolate); | 2722 Handle<Map> map(heap_object->map(), isolate); |
2721 bit_field_ = IsNotInNewSpaceField::update( | 2723 bit_field_ = IsNotInNewSpaceField::update( |
2722 bit_field_, !isolate->heap()->InNewSpace(*object)); | 2724 bit_field_, !isolate->heap()->InNewSpace(*object)); |
2723 bit_field_ = InstanceTypeField::update(bit_field_, map->instance_type()); | 2725 bit_field_ = InstanceTypeField::update(bit_field_, map->instance_type()); |
2724 bit_field_ = | 2726 bit_field_ = |
2725 IsUndetectableField::update(bit_field_, map->is_undetectable()); | 2727 IsUndetectableField::update(bit_field_, map->is_undetectable()); |
| 2728 bit_field_ = IsCallableField::update(bit_field_, map->is_callable()); |
2726 if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map); | 2729 if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map); |
2727 bit_field_ = HasStableMapValueField::update( | 2730 bit_field_ = HasStableMapValueField::update( |
2728 bit_field_, | 2731 bit_field_, |
2729 HasMapValue() && Handle<Map>::cast(heap_object)->is_stable()); | 2732 HasMapValue() && Handle<Map>::cast(heap_object)->is_stable()); |
2730 } | 2733 } |
2731 if (object->IsNumber()) { | 2734 if (object->IsNumber()) { |
2732 double n = object->Number(); | 2735 double n = object->Number(); |
2733 bool has_int32_value = IsInteger32(n); | 2736 bool has_int32_value = IsInteger32(n); |
2734 bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value); | 2737 bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value); |
2735 int32_value_ = DoubleToInt32(n); | 2738 int32_value_ = DoubleToInt32(n); |
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4708 case HObjectAccess::kExternalMemory: | 4711 case HObjectAccess::kExternalMemory: |
4709 os << "[external-memory]"; | 4712 os << "[external-memory]"; |
4710 break; | 4713 break; |
4711 } | 4714 } |
4712 | 4715 |
4713 return os << "@" << access.offset(); | 4716 return os << "@" << access.offset(); |
4714 } | 4717 } |
4715 | 4718 |
4716 } // namespace internal | 4719 } // namespace internal |
4717 } // namespace v8 | 4720 } // namespace v8 |
OLD | NEW |