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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 23604062: Use UniqueSet<T> and Unique<T> in HCheckMaps and HCheckValue. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
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 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, 1424 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect,
1425 HValue* dominator) { 1425 HValue* dominator) {
1426 ASSERT(side_effect == kChangesMaps); 1426 ASSERT(side_effect == kChangesMaps);
1427 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once 1427 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once
1428 // type information is rich enough we should generalize this to any HType 1428 // type information is rich enough we should generalize this to any HType
1429 // for which the map is known. 1429 // for which the map is known.
1430 if (HasNoUses() && dominator->IsStoreNamedField()) { 1430 if (HasNoUses() && dominator->IsStoreNamedField()) {
1431 HStoreNamedField* store = HStoreNamedField::cast(dominator); 1431 HStoreNamedField* store = HStoreNamedField::cast(dominator);
1432 if (!store->has_transition() || store->object() != value()) return; 1432 if (!store->has_transition() || store->object() != value()) return;
1433 HConstant* transition = HConstant::cast(store->transition()); 1433 HConstant* transition = HConstant::cast(store->transition());
1434 for (int i = 0; i < map_set()->length(); i++) { 1434 if (map_set_.Contains(transition->GetUnique())) {
1435 if (transition->UniqueValueIdsMatch(map_unique_ids_.at(i))) { 1435 DeleteAndReplaceWith(NULL);
1436 DeleteAndReplaceWith(NULL); 1436 return;
1437 return;
1438 }
1439 } 1437 }
1440 } 1438 }
1441 } 1439 }
1442 1440
1443 1441
1444 void HCheckMaps::PrintDataTo(StringStream* stream) { 1442 void HCheckMaps::PrintDataTo(StringStream* stream) {
1445 value()->PrintNameTo(stream); 1443 value()->PrintNameTo(stream);
1446 stream->Add(" [%p", *map_set()->first()); 1444 stream->Add(" [%p", *map_set_.at(0).handle());
1447 for (int i = 1; i < map_set()->length(); ++i) { 1445 for (int i = 1; i < map_set_.size(); ++i) {
1448 stream->Add(",%p", *map_set()->at(i)); 1446 stream->Add(",%p", *map_set_.at(i).handle());
1449 } 1447 }
1450 stream->Add("]%s", CanOmitMapChecks() ? "(omitted)" : ""); 1448 stream->Add("]%s", CanOmitMapChecks() ? "(omitted)" : "");
1451 } 1449 }
1452 1450
1453 1451
1454 void HCheckValue::PrintDataTo(StringStream* stream) { 1452 void HCheckValue::PrintDataTo(StringStream* stream) {
1455 value()->PrintNameTo(stream); 1453 value()->PrintNameTo(stream);
1456 stream->Add(" "); 1454 stream->Add(" ");
1457 object()->ShortPrint(stream); 1455 object().handle()->ShortPrint(stream);
1458 } 1456 }
1459 1457
1460 1458
1461 HValue* HCheckValue::Canonicalize() { 1459 HValue* HCheckValue::Canonicalize() {
1462 return (value()->IsConstant() && 1460 return (value()->IsConstant() &&
1463 HConstant::cast(value())->UniqueValueIdsMatch(object_unique_id_)) 1461 HConstant::cast(value())->GetUnique() == object_)
1464 ? NULL 1462 ? NULL
1465 : this; 1463 : this;
1466 } 1464 }
1467 1465
1468 1466
1469 const char* HCheckInstanceType::GetCheckName() { 1467 const char* HCheckInstanceType::GetCheckName() {
1470 switch (check_) { 1468 switch (check_) {
1471 case IS_SPEC_OBJECT: return "object"; 1469 case IS_SPEC_OBJECT: return "object";
1472 case IS_JS_ARRAY: return "array"; 1470 case IS_JS_ARRAY: return "array";
1473 case IS_STRING: return "string"; 1471 case IS_STRING: return "string";
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2932 HValue* context, 2930 HValue* context,
2933 HValue* value, 2931 HValue* value,
2934 Handle<Map> map, 2932 Handle<Map> map,
2935 CompilationInfo* info, 2933 CompilationInfo* info,
2936 HValue* typecheck) { 2934 HValue* typecheck) {
2937 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); 2935 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck);
2938 check_map->Add(map, zone); 2936 check_map->Add(map, zone);
2939 if (map->CanOmitMapChecks() && 2937 if (map->CanOmitMapChecks() &&
2940 value->IsConstant() && 2938 value->IsConstant() &&
2941 HConstant::cast(value)->HasMap(map)) { 2939 HConstant::cast(value)->HasMap(map)) {
2942 check_map->omit(info); 2940 // TODO(titzer): collect dependent map checks into a list.
2941 check_map->omit_ = true;
2942 if (map->CanTransition()) {
2943 map->AddDependentCompilationInfo(
2944 DependentCode::kPrototypeCheckGroup, info);
2945 }
2943 } 2946 }
2944 return check_map; 2947 return check_map;
2945 } 2948 }
2946 2949
2947 2950
2948 void HCheckMaps::FinalizeUniqueValueId() {
2949 if (!map_unique_ids_.is_empty()) return;
2950 Zone* zone = block()->zone();
2951 map_unique_ids_.Initialize(map_set_.length(), zone);
2952 for (int i = 0; i < map_set_.length(); i++) {
2953 map_unique_ids_.Add(UniqueValueId(map_set_.at(i)), zone);
2954 }
2955 }
2956
2957
2958 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { 2951 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) {
2959 object()->PrintNameTo(stream); 2952 object()->PrintNameTo(stream);
2960 stream->Add("."); 2953 stream->Add(".");
2961 stream->Add(*String::cast(*name())->ToCString()); 2954 stream->Add(*String::cast(*name())->ToCString());
2962 } 2955 }
2963 2956
2964 2957
2965 void HLoadKeyed::PrintDataTo(StringStream* stream) { 2958 void HLoadKeyed::PrintDataTo(StringStream* stream) {
2966 if (!is_external()) { 2959 if (!is_external()) {
2967 elements()->PrintNameTo(stream); 2960 elements()->PrintNameTo(stream);
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 break; 4233 break;
4241 case kExternalMemory: 4234 case kExternalMemory:
4242 stream->Add("[external-memory]"); 4235 stream->Add("[external-memory]");
4243 break; 4236 break;
4244 } 4237 }
4245 4238
4246 stream->Add("@%d", offset()); 4239 stream->Add("@%d", offset());
4247 } 4240 }
4248 4241
4249 } } // namespace v8::internal 4242 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698