| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 } | 1047 } |
| 1048 if (expected_input_types_.Contains(ToBooleanStub::SMI)) { | 1048 if (expected_input_types_.Contains(ToBooleanStub::SMI)) { |
| 1049 return Representation::Smi(); | 1049 return Representation::Smi(); |
| 1050 } | 1050 } |
| 1051 return Representation::None(); | 1051 return Representation::None(); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 | 1054 |
| 1055 void HCompareMap::PrintDataTo(StringStream* stream) { | 1055 void HCompareMap::PrintDataTo(StringStream* stream) { |
| 1056 value()->PrintNameTo(stream); | 1056 value()->PrintNameTo(stream); |
| 1057 stream->Add(" (%p)", *map()); | 1057 stream->Add(" (%p)", *map().handle()); |
| 1058 HControlInstruction::PrintDataTo(stream); | 1058 HControlInstruction::PrintDataTo(stream); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 | 1061 |
| 1062 const char* HUnaryMathOperation::OpName() const { | 1062 const char* HUnaryMathOperation::OpName() const { |
| 1063 switch (op()) { | 1063 switch (op()) { |
| 1064 case kMathFloor: return "floor"; | 1064 case kMathFloor: return "floor"; |
| 1065 case kMathRound: return "round"; | 1065 case kMathRound: return "round"; |
| 1066 case kMathAbs: return "abs"; | 1066 case kMathAbs: return "abs"; |
| 1067 case kMathLog: return "log"; | 1067 case kMathLog: return "log"; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, | 1426 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, |
| 1427 HValue* dominator) { | 1427 HValue* dominator) { |
| 1428 ASSERT(side_effect == kChangesMaps); | 1428 ASSERT(side_effect == kChangesMaps); |
| 1429 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once | 1429 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once |
| 1430 // type information is rich enough we should generalize this to any HType | 1430 // type information is rich enough we should generalize this to any HType |
| 1431 // for which the map is known. | 1431 // for which the map is known. |
| 1432 if (HasNoUses() && dominator->IsStoreNamedField()) { | 1432 if (HasNoUses() && dominator->IsStoreNamedField()) { |
| 1433 HStoreNamedField* store = HStoreNamedField::cast(dominator); | 1433 HStoreNamedField* store = HStoreNamedField::cast(dominator); |
| 1434 if (!store->has_transition() || store->object() != value()) return; | 1434 if (!store->has_transition() || store->object() != value()) return; |
| 1435 HConstant* transition = HConstant::cast(store->transition()); | 1435 HConstant* transition = HConstant::cast(store->transition()); |
| 1436 for (int i = 0; i < map_set()->length(); i++) { | 1436 if (map_set_.Contains(transition->GetUnique())) { |
| 1437 if (transition->UniqueValueIdsMatch(map_unique_ids_.at(i))) { | 1437 DeleteAndReplaceWith(NULL); |
| 1438 DeleteAndReplaceWith(NULL); | 1438 return; |
| 1439 return; | |
| 1440 } | |
| 1441 } | 1439 } |
| 1442 } | 1440 } |
| 1443 } | 1441 } |
| 1444 | 1442 |
| 1445 | 1443 |
| 1446 void HCheckMaps::PrintDataTo(StringStream* stream) { | 1444 void HCheckMaps::PrintDataTo(StringStream* stream) { |
| 1447 value()->PrintNameTo(stream); | 1445 value()->PrintNameTo(stream); |
| 1448 stream->Add(" [%p", *map_set()->first()); | 1446 stream->Add(" [%p", *map_set_.at(0).handle()); |
| 1449 for (int i = 1; i < map_set()->length(); ++i) { | 1447 for (int i = 1; i < map_set_.size(); ++i) { |
| 1450 stream->Add(",%p", *map_set()->at(i)); | 1448 stream->Add(",%p", *map_set_.at(i).handle()); |
| 1451 } | 1449 } |
| 1452 stream->Add("]%s", CanOmitMapChecks() ? "(omitted)" : ""); | 1450 stream->Add("]%s", CanOmitMapChecks() ? "(omitted)" : ""); |
| 1453 } | 1451 } |
| 1454 | 1452 |
| 1455 | 1453 |
| 1456 void HCheckValue::PrintDataTo(StringStream* stream) { | 1454 void HCheckValue::PrintDataTo(StringStream* stream) { |
| 1457 value()->PrintNameTo(stream); | 1455 value()->PrintNameTo(stream); |
| 1458 stream->Add(" "); | 1456 stream->Add(" "); |
| 1459 object()->ShortPrint(stream); | 1457 object().handle()->ShortPrint(stream); |
| 1460 } | 1458 } |
| 1461 | 1459 |
| 1462 | 1460 |
| 1463 HValue* HCheckValue::Canonicalize() { | 1461 HValue* HCheckValue::Canonicalize() { |
| 1464 return (value()->IsConstant() && | 1462 return (value()->IsConstant() && |
| 1465 HConstant::cast(value())->UniqueValueIdsMatch(object_unique_id_)) | 1463 HConstant::cast(value())->GetUnique() == object_) |
| 1466 ? NULL | 1464 ? NULL |
| 1467 : this; | 1465 : this; |
| 1468 } | 1466 } |
| 1469 | 1467 |
| 1470 | 1468 |
| 1471 const char* HCheckInstanceType::GetCheckName() { | 1469 const char* HCheckInstanceType::GetCheckName() { |
| 1472 switch (check_) { | 1470 switch (check_) { |
| 1473 case IS_SPEC_OBJECT: return "object"; | 1471 case IS_SPEC_OBJECT: return "object"; |
| 1474 case IS_JS_ARRAY: return "array"; | 1472 case IS_JS_ARRAY: return "array"; |
| 1475 case IS_STRING: return "string"; | 1473 case IS_STRING: return "string"; |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 if (has_int32_value_) { | 2568 if (has_int32_value_) { |
| 2571 res = new(zone) HConstant(int32_value_, | 2569 res = new(zone) HConstant(int32_value_, |
| 2572 Representation::Integer32(), | 2570 Representation::Integer32(), |
| 2573 is_not_in_new_space_, | 2571 is_not_in_new_space_, |
| 2574 handle_); | 2572 handle_); |
| 2575 } else if (has_double_value_) { | 2573 } else if (has_double_value_) { |
| 2576 res = new(zone) HConstant(DoubleToInt32(double_value_), | 2574 res = new(zone) HConstant(DoubleToInt32(double_value_), |
| 2577 Representation::Integer32(), | 2575 Representation::Integer32(), |
| 2578 is_not_in_new_space_, | 2576 is_not_in_new_space_, |
| 2579 handle_); | 2577 handle_); |
| 2580 } else { | |
| 2581 ASSERT(!HasNumberValue()); | |
| 2582 Maybe<HConstant*> number = CopyToTruncatedNumber(zone); | |
| 2583 if (number.has_value) return number.value->CopyToTruncatedInt32(zone); | |
| 2584 } | 2578 } |
| 2585 return Maybe<HConstant*>(res != NULL, res); | 2579 return Maybe<HConstant*>(res != NULL, res); |
| 2586 } | 2580 } |
| 2587 | 2581 |
| 2588 | 2582 |
| 2589 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { | 2583 Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) { |
| 2590 HConstant* res = NULL; | 2584 HConstant* res = NULL; |
| 2591 Handle<Object> handle = this->handle(zone->isolate()); | 2585 Handle<Object> handle = this->handle(zone->isolate()); |
| 2592 if (handle->IsBoolean()) { | 2586 if (handle->IsBoolean()) { |
| 2593 res = handle->BooleanValue() ? | 2587 res = handle->BooleanValue() ? |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2856 | 2850 |
| 2857 | 2851 |
| 2858 void HCompareObjectEqAndBranch::PrintDataTo(StringStream* stream) { | 2852 void HCompareObjectEqAndBranch::PrintDataTo(StringStream* stream) { |
| 2859 left()->PrintNameTo(stream); | 2853 left()->PrintNameTo(stream); |
| 2860 stream->Add(" "); | 2854 stream->Add(" "); |
| 2861 right()->PrintNameTo(stream); | 2855 right()->PrintNameTo(stream); |
| 2862 HControlInstruction::PrintDataTo(stream); | 2856 HControlInstruction::PrintDataTo(stream); |
| 2863 } | 2857 } |
| 2864 | 2858 |
| 2865 | 2859 |
| 2866 void HCompareHoleAndBranch::PrintDataTo(StringStream* stream) { | |
| 2867 object()->PrintNameTo(stream); | |
| 2868 HControlInstruction::PrintDataTo(stream); | |
| 2869 } | |
| 2870 | |
| 2871 | |
| 2872 void HCompareHoleAndBranch::InferRepresentation( | 2860 void HCompareHoleAndBranch::InferRepresentation( |
| 2873 HInferRepresentationPhase* h_infer) { | 2861 HInferRepresentationPhase* h_infer) { |
| 2874 ChangeRepresentation(object()->representation()); | 2862 ChangeRepresentation(value()->representation()); |
| 2875 } | 2863 } |
| 2876 | 2864 |
| 2877 | 2865 |
| 2878 void HGoto::PrintDataTo(StringStream* stream) { | 2866 void HGoto::PrintDataTo(StringStream* stream) { |
| 2879 stream->Add("B%d", SuccessorAt(0)->block_id()); | 2867 stream->Add("B%d", SuccessorAt(0)->block_id()); |
| 2880 } | 2868 } |
| 2881 | 2869 |
| 2882 | 2870 |
| 2883 void HCompareNumericAndBranch::InferRepresentation( | 2871 void HCompareNumericAndBranch::InferRepresentation( |
| 2884 HInferRepresentationPhase* h_infer) { | 2872 HInferRepresentationPhase* h_infer) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2934 HValue* context, | 2922 HValue* context, |
| 2935 HValue* value, | 2923 HValue* value, |
| 2936 Handle<Map> map, | 2924 Handle<Map> map, |
| 2937 CompilationInfo* info, | 2925 CompilationInfo* info, |
| 2938 HValue* typecheck) { | 2926 HValue* typecheck) { |
| 2939 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); | 2927 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); |
| 2940 check_map->Add(map, zone); | 2928 check_map->Add(map, zone); |
| 2941 if (map->CanOmitMapChecks() && | 2929 if (map->CanOmitMapChecks() && |
| 2942 value->IsConstant() && | 2930 value->IsConstant() && |
| 2943 HConstant::cast(value)->HasMap(map)) { | 2931 HConstant::cast(value)->HasMap(map)) { |
| 2944 check_map->omit(info); | 2932 // TODO(titzer): collect dependent map checks into a list. |
| 2933 check_map->omit_ = true; |
| 2934 if (map->CanTransition()) { |
| 2935 map->AddDependentCompilationInfo( |
| 2936 DependentCode::kPrototypeCheckGroup, info); |
| 2937 } |
| 2945 } | 2938 } |
| 2946 return check_map; | 2939 return check_map; |
| 2947 } | 2940 } |
| 2948 | 2941 |
| 2949 | 2942 |
| 2950 void HCheckMaps::FinalizeUniqueValueId() { | |
| 2951 if (!map_unique_ids_.is_empty()) return; | |
| 2952 Zone* zone = block()->zone(); | |
| 2953 map_unique_ids_.Initialize(map_set_.length(), zone); | |
| 2954 for (int i = 0; i < map_set_.length(); i++) { | |
| 2955 map_unique_ids_.Add(UniqueValueId(map_set_.at(i)), zone); | |
| 2956 } | |
| 2957 } | |
| 2958 | |
| 2959 | |
| 2960 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { | 2943 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { |
| 2961 object()->PrintNameTo(stream); | 2944 object()->PrintNameTo(stream); |
| 2962 stream->Add("."); | 2945 stream->Add("."); |
| 2963 stream->Add(*String::cast(*name())->ToCString()); | 2946 stream->Add(*String::cast(*name())->ToCString()); |
| 2964 } | 2947 } |
| 2965 | 2948 |
| 2966 | 2949 |
| 2967 void HLoadKeyed::PrintDataTo(StringStream* stream) { | 2950 void HLoadKeyed::PrintDataTo(StringStream* stream) { |
| 2968 if (!is_external()) { | 2951 if (!is_external()) { |
| 2969 elements()->PrintNameTo(stream); | 2952 elements()->PrintNameTo(stream); |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4242 break; | 4225 break; |
| 4243 case kExternalMemory: | 4226 case kExternalMemory: |
| 4244 stream->Add("[external-memory]"); | 4227 stream->Add("[external-memory]"); |
| 4245 break; | 4228 break; |
| 4246 } | 4229 } |
| 4247 | 4230 |
| 4248 stream->Add("@%d", offset()); | 4231 stream->Add("@%d", offset()); |
| 4249 } | 4232 } |
| 4250 | 4233 |
| 4251 } } // namespace v8::internal | 4234 } } // namespace v8::internal |
| OLD | NEW |