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

Side by Side Diff: src/hydrogen.cc

Issue 19954005: Eliminate map checks of constant values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Naming Created 7 years, 5 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/flag-definitions.h ('k') | src/hydrogen-instructions.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1038
1039 1039
1040 HValue* HGraphBuilder::BuildCheckHeapObject(HValue* obj) { 1040 HValue* HGraphBuilder::BuildCheckHeapObject(HValue* obj) {
1041 if (obj->type().IsHeapObject()) return obj; 1041 if (obj->type().IsHeapObject()) return obj;
1042 return Add<HCheckHeapObject>(obj); 1042 return Add<HCheckHeapObject>(obj);
1043 } 1043 }
1044 1044
1045 1045
1046 HValue* HGraphBuilder::BuildCheckMap(HValue* obj, 1046 HValue* HGraphBuilder::BuildCheckMap(HValue* obj,
1047 Handle<Map> map) { 1047 Handle<Map> map) {
1048 HCheckMaps* check = HCheckMaps::New(obj, map, zone()); 1048 HCheckMaps* check = HCheckMaps::New(obj, map, zone(), top_info());
1049 AddInstruction(check); 1049 AddInstruction(check);
1050 return check; 1050 return check;
1051 } 1051 }
1052 1052
1053 1053
1054 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, 1054 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
1055 HValue* elements, 1055 HValue* elements,
1056 ElementsKind kind, 1056 ElementsKind kind,
1057 HValue* length, 1057 HValue* length,
1058 HValue* key, 1058 HValue* key,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 if (mapcheck != NULL) { 1201 if (mapcheck != NULL) {
1202 mapcheck->ClearGVNFlag(kDependsOnElementsKind); 1202 mapcheck->ClearGVNFlag(kDependsOnElementsKind);
1203 } 1203 }
1204 } 1204 }
1205 bool fast_smi_only_elements = IsFastSmiElementsKind(elements_kind); 1205 bool fast_smi_only_elements = IsFastSmiElementsKind(elements_kind);
1206 bool fast_elements = IsFastObjectElementsKind(elements_kind); 1206 bool fast_elements = IsFastObjectElementsKind(elements_kind);
1207 HValue* elements = AddLoadElements(object, mapcheck); 1207 HValue* elements = AddLoadElements(object, mapcheck);
1208 if (is_store && (fast_elements || fast_smi_only_elements) && 1208 if (is_store && (fast_elements || fast_smi_only_elements) &&
1209 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { 1209 store_mode != STORE_NO_TRANSITION_HANDLE_COW) {
1210 HCheckMaps* check_cow_map = HCheckMaps::New( 1210 HCheckMaps* check_cow_map = HCheckMaps::New(
1211 elements, isolate()->factory()->fixed_array_map(), zone); 1211 elements, isolate()->factory()->fixed_array_map(), zone, top_info());
1212 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); 1212 check_cow_map->ClearGVNFlag(kDependsOnElementsKind);
1213 AddInstruction(check_cow_map); 1213 AddInstruction(check_cow_map);
1214 } 1214 }
1215 HInstruction* length = NULL; 1215 HInstruction* length = NULL;
1216 if (is_js_array) { 1216 if (is_js_array) {
1217 length = AddLoad(object, HObjectAccess::ForArrayLength(), mapcheck, 1217 length = AddLoad(object, HObjectAccess::ForArrayLength(), mapcheck,
1218 Representation::Smi()); 1218 Representation::Smi());
1219 } else { 1219 } else {
1220 length = AddLoadFixedArrayLength(elements); 1220 length = AddLoadFixedArrayLength(elements);
1221 } 1221 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 checked_key = Add<HBoundsCheck>(key, length); 1269 checked_key = Add<HBoundsCheck>(key, length);
1270 1270
1271 if (is_store && (fast_elements || fast_smi_only_elements)) { 1271 if (is_store && (fast_elements || fast_smi_only_elements)) {
1272 if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) { 1272 if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) {
1273 NoObservableSideEffectsScope no_effects(this); 1273 NoObservableSideEffectsScope no_effects(this);
1274 1274
1275 elements = BuildCopyElementsOnWrite(object, elements, elements_kind, 1275 elements = BuildCopyElementsOnWrite(object, elements, elements_kind,
1276 length); 1276 length);
1277 } else { 1277 } else {
1278 HCheckMaps* check_cow_map = HCheckMaps::New( 1278 HCheckMaps* check_cow_map = HCheckMaps::New(
1279 elements, isolate()->factory()->fixed_array_map(), zone); 1279 elements, isolate()->factory()->fixed_array_map(),
1280 zone, top_info());
1280 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); 1281 check_cow_map->ClearGVNFlag(kDependsOnElementsKind);
1281 AddInstruction(check_cow_map); 1282 AddInstruction(check_cow_map);
1282 } 1283 }
1283 } 1284 }
1284 } 1285 }
1285 return AddFastElementAccess(elements, checked_key, val, mapcheck, 1286 return AddFastElementAccess(elements, checked_key, val, mapcheck,
1286 elements_kind, is_store, load_mode, store_mode); 1287 elements_kind, is_store, load_mode, store_mode);
1287 } 1288 }
1288 1289
1289 1290
(...skipping 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after
4443 Runtime::FunctionId function_id = (expr->depth() > 1) 4444 Runtime::FunctionId function_id = (expr->depth() > 1)
4444 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow; 4445 ? Runtime::kCreateArrayLiteral : Runtime::kCreateArrayLiteralShallow;
4445 literal = Add<HCallRuntime>(context, 4446 literal = Add<HCallRuntime>(context,
4446 isolate()->factory()->empty_string(), 4447 isolate()->factory()->empty_string(),
4447 Runtime::FunctionForId(function_id), 4448 Runtime::FunctionForId(function_id),
4448 3); 4449 3);
4449 4450
4450 // De-opt if elements kind changed from boilerplate_elements_kind. 4451 // De-opt if elements kind changed from boilerplate_elements_kind.
4451 Handle<Map> map = Handle<Map>(original_boilerplate_object->map(), 4452 Handle<Map> map = Handle<Map>(original_boilerplate_object->map(),
4452 isolate()); 4453 isolate());
4453 AddInstruction(HCheckMaps::New(literal, map, zone())); 4454 AddInstruction(HCheckMaps::New(literal, map, zone(), top_info()));
4454 } 4455 }
4455 4456
4456 // The array is expected in the bailout environment during computation 4457 // The array is expected in the bailout environment during computation
4457 // of the property values and is the value of the entire expression. 4458 // of the property values and is the value of the entire expression.
4458 Push(literal); 4459 Push(literal);
4459 // The literal index is on the stack, too. 4460 // The literal index is on the stack, too.
4460 Push(Add<HConstant>(expr->literal_index())); 4461 Push(Add<HConstant>(expr->literal_index()));
4461 4462
4462 HInstruction* elements = NULL; 4463 HInstruction* elements = NULL;
4463 4464
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4534 int descriptor = transition->LastAdded(); 4535 int descriptor = transition->LastAdded();
4535 PropertyDetails details = 4536 PropertyDetails details =
4536 transition->instance_descriptors()->GetDetails(descriptor); 4537 transition->instance_descriptors()->GetDetails(descriptor);
4537 return details.representation(); 4538 return details.representation();
4538 } 4539 }
4539 } 4540 }
4540 4541
4541 4542
4542 void HOptimizedGraphBuilder::AddCheckMap(HValue* object, Handle<Map> map) { 4543 void HOptimizedGraphBuilder::AddCheckMap(HValue* object, Handle<Map> map) {
4543 BuildCheckHeapObject(object); 4544 BuildCheckHeapObject(object);
4544 AddInstruction(HCheckMaps::New(object, map, zone())); 4545 AddInstruction(HCheckMaps::New(object, map, zone(), top_info()));
4545 } 4546 }
4546 4547
4547 4548
4548 void HOptimizedGraphBuilder::AddCheckMapsWithTransitions(HValue* object, 4549 void HOptimizedGraphBuilder::AddCheckMapsWithTransitions(HValue* object,
4549 Handle<Map> map) { 4550 Handle<Map> map) {
4550 BuildCheckHeapObject(object); 4551 BuildCheckHeapObject(object);
4551 AddInstruction(HCheckMaps::NewWithTransitions(object, map, zone())); 4552 AddInstruction(HCheckMaps::NewWithTransitions(object, map, zone()));
4552 } 4553 }
4553 4554
4554 4555
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
5499 5500
5500 5501
5501 HInstruction* HOptimizedGraphBuilder::BuildMonomorphicElementAccess( 5502 HInstruction* HOptimizedGraphBuilder::BuildMonomorphicElementAccess(
5502 HValue* object, 5503 HValue* object,
5503 HValue* key, 5504 HValue* key,
5504 HValue* val, 5505 HValue* val,
5505 HValue* dependency, 5506 HValue* dependency,
5506 Handle<Map> map, 5507 Handle<Map> map,
5507 bool is_store, 5508 bool is_store,
5508 KeyedAccessStoreMode store_mode) { 5509 KeyedAccessStoreMode store_mode) {
5509 HCheckMaps* mapcheck = HCheckMaps::New(object, map, zone(), dependency); 5510 HCheckMaps* mapcheck = HCheckMaps::New(
5511 object, map, zone(), top_info(), dependency);
5510 AddInstruction(mapcheck); 5512 AddInstruction(mapcheck);
5511 if (dependency) { 5513 if (dependency) {
5512 mapcheck->ClearGVNFlag(kDependsOnElementsKind); 5514 mapcheck->ClearGVNFlag(kDependsOnElementsKind);
5513 } 5515 }
5514 5516
5515 // Loads from a "stock" fast holey double arrays can elide the hole check. 5517 // Loads from a "stock" fast holey double arrays can elide the hole check.
5516 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; 5518 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE;
5517 if (*map == isolate()->get_initial_js_array_map(FAST_HOLEY_DOUBLE_ELEMENTS) && 5519 if (*map == isolate()->get_initial_js_array_map(FAST_HOLEY_DOUBLE_ELEMENTS) &&
5518 isolate()->IsFastArrayConstructorPrototypeChainIntact()) { 5520 isolate()->IsFastArrayConstructorPrototypeChainIntact()) {
5519 Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate()); 5521 Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate());
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5683 new(zone()) HCompareMap(object, map, this_map, other_map); 5685 new(zone()) HCompareMap(object, map, this_map, other_map);
5684 current_block()->Finish(mapcompare); 5686 current_block()->Finish(mapcompare);
5685 5687
5686 set_current_block(this_map); 5688 set_current_block(this_map);
5687 HInstruction* checked_key = NULL; 5689 HInstruction* checked_key = NULL;
5688 HInstruction* access = NULL; 5690 HInstruction* access = NULL;
5689 if (IsFastElementsKind(elements_kind)) { 5691 if (IsFastElementsKind(elements_kind)) {
5690 if (is_store && !IsFastDoubleElementsKind(elements_kind)) { 5692 if (is_store && !IsFastDoubleElementsKind(elements_kind)) {
5691 AddInstruction(HCheckMaps::New( 5693 AddInstruction(HCheckMaps::New(
5692 elements, isolate()->factory()->fixed_array_map(), 5694 elements, isolate()->factory()->fixed_array_map(),
5693 zone(), mapcompare)); 5695 zone(), top_info(), mapcompare));
5694 } 5696 }
5695 if (map->IsJSArray()) { 5697 if (map->IsJSArray()) {
5696 HInstruction* length = AddLoad(object, HObjectAccess::ForArrayLength(), 5698 HInstruction* length = AddLoad(object, HObjectAccess::ForArrayLength(),
5697 mapcompare, Representation::Smi()); 5699 mapcompare, Representation::Smi());
5698 length->set_type(HType::Smi()); 5700 length->set_type(HType::Smi());
5699 checked_key = Add<HBoundsCheck>(key, length); 5701 checked_key = Add<HBoundsCheck>(key, length);
5700 } else { 5702 } else {
5701 HInstruction* length = AddLoadFixedArrayLength(elements); 5703 HInstruction* length = AddLoadFixedArrayLength(elements);
5702 checked_key = Add<HBoundsCheck>(key, length); 5704 checked_key = Add<HBoundsCheck>(key, length);
5703 } 5705 }
(...skipping 4200 matching lines...) Expand 10 before | Expand all | Expand 10 after
9904 if (ShouldProduceTraceOutput()) { 9906 if (ShouldProduceTraceOutput()) {
9905 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9907 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9906 } 9908 }
9907 9909
9908 #ifdef DEBUG 9910 #ifdef DEBUG
9909 graph_->Verify(false); // No full verify. 9911 graph_->Verify(false); // No full verify.
9910 #endif 9912 #endif
9911 } 9913 }
9912 9914
9913 } } // namespace v8::internal 9915 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698