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

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: Use an uninitialized Unique<T> in HCheckMaps. 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
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 HValue* context, 2926 HValue* context,
2929 HValue* value, 2927 HValue* value,
2930 Handle<Map> map, 2928 Handle<Map> map,
2931 CompilationInfo* info, 2929 CompilationInfo* info,
2932 HValue* typecheck) { 2930 HValue* typecheck) {
2933 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); 2931 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck);
2934 check_map->Add(map, zone); 2932 check_map->Add(map, zone);
2935 if (map->CanOmitMapChecks() && 2933 if (map->CanOmitMapChecks() &&
2936 value->IsConstant() && 2934 value->IsConstant() &&
2937 HConstant::cast(value)->HasMap(map)) { 2935 HConstant::cast(value)->HasMap(map)) {
2938 check_map->omit(info); 2936 // TODO(titzer): collect dependent map checks into a list.
2937 check_map->omit_ = true;
2938 if (map->CanTransition()) {
2939 map->AddDependentCompilationInfo(
2940 DependentCode::kPrototypeCheckGroup, info);
2941 }
2939 } 2942 }
2940 return check_map; 2943 return check_map;
2941 } 2944 }
2942 2945
2943 2946
2944 void HCheckMaps::FinalizeUniqueValueId() {
2945 if (!map_unique_ids_.is_empty()) return;
2946 Zone* zone = block()->zone();
2947 map_unique_ids_.Initialize(map_set_.length(), zone);
2948 for (int i = 0; i < map_set_.length(); i++) {
2949 map_unique_ids_.Add(UniqueValueId(map_set_.at(i)), zone);
2950 }
2951 }
2952
2953
2954 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { 2947 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) {
2955 object()->PrintNameTo(stream); 2948 object()->PrintNameTo(stream);
2956 stream->Add("."); 2949 stream->Add(".");
2957 stream->Add(*String::cast(*name())->ToCString()); 2950 stream->Add(*String::cast(*name())->ToCString());
2958 } 2951 }
2959 2952
2960 2953
2961 void HLoadKeyed::PrintDataTo(StringStream* stream) { 2954 void HLoadKeyed::PrintDataTo(StringStream* stream) {
2962 if (!is_external()) { 2955 if (!is_external()) {
2963 elements()->PrintNameTo(stream); 2956 elements()->PrintNameTo(stream);
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
4236 break; 4229 break;
4237 case kExternalMemory: 4230 case kExternalMemory:
4238 stream->Add("[external-memory]"); 4231 stream->Add("[external-memory]");
4239 break; 4232 break;
4240 } 4233 }
4241 4234
4242 stream->Add("@%d", offset()); 4235 stream->Add("@%d", offset());
4243 } 4236 }
4244 4237
4245 } } // namespace v8::internal 4238 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698