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

Side by Side Diff: src/hydrogen.cc

Issue 9252008: Eliminate a superfluous map check when building a generic array element access. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 11 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 | « no previous file | src/objects.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 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 4248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4259 4259
4260 4260
4261 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, 4261 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object,
4262 HValue* key, 4262 HValue* key,
4263 HValue* val, 4263 HValue* val,
4264 Handle<Map> map, 4264 Handle<Map> map,
4265 bool is_store) { 4265 bool is_store) {
4266 HInstruction* mapcheck = AddInstruction(new(zone()) HCheckMap(object, map)); 4266 HInstruction* mapcheck = AddInstruction(new(zone()) HCheckMap(object, map));
4267 bool fast_smi_only_elements = map->has_fast_smi_only_elements(); 4267 bool fast_smi_only_elements = map->has_fast_smi_only_elements();
4268 bool fast_elements = map->has_fast_elements(); 4268 bool fast_elements = map->has_fast_elements();
4269 bool fast_double_elements = map->has_fast_double_elements();
4270 if (!fast_smi_only_elements &&
4271 !fast_elements &&
4272 !fast_double_elements &&
4273 !map->has_external_array_elements()) {
4274 return is_store ? BuildStoreKeyedGeneric(object, key, val)
4275 : BuildLoadKeyedGeneric(object, key);
4276 }
4277 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object)); 4269 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object));
4278 if (is_store && (fast_elements || fast_smi_only_elements)) { 4270 if (is_store && (fast_elements || fast_smi_only_elements)) {
4279 AddInstruction(new(zone()) HCheckMap( 4271 AddInstruction(new(zone()) HCheckMap(
4280 elements, isolate()->factory()->fixed_array_map())); 4272 elements, isolate()->factory()->fixed_array_map()));
4281 } 4273 }
4282 HInstruction* length = NULL; 4274 HInstruction* length = NULL;
4283 HInstruction* checked_key = NULL; 4275 HInstruction* checked_key = NULL;
4284 if (map->has_external_array_elements()) { 4276 if (map->has_external_array_elements()) {
4285 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); 4277 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
4286 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); 4278 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
4287 HLoadExternalArrayPointer* external_elements = 4279 HLoadExternalArrayPointer* external_elements =
4288 new(zone()) HLoadExternalArrayPointer(elements); 4280 new(zone()) HLoadExternalArrayPointer(elements);
4289 AddInstruction(external_elements); 4281 AddInstruction(external_elements);
4290 return BuildExternalArrayElementAccess(external_elements, checked_key, 4282 return BuildExternalArrayElementAccess(external_elements, checked_key,
4291 val, map->elements_kind(), is_store); 4283 val, map->elements_kind(), is_store);
4292 } 4284 }
4293 ASSERT(fast_smi_only_elements || fast_elements || fast_double_elements); 4285 ASSERT(fast_smi_only_elements ||
4286 fast_elements ||
4287 map->has_fast_double_elements());
4294 if (map->instance_type() == JS_ARRAY_TYPE) { 4288 if (map->instance_type() == JS_ARRAY_TYPE) {
4295 length = AddInstruction(new(zone()) HJSArrayLength(object, mapcheck)); 4289 length = AddInstruction(new(zone()) HJSArrayLength(object, mapcheck));
4296 } else { 4290 } else {
4297 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); 4291 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
4298 } 4292 }
4299 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); 4293 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
4300 return BuildFastElementAccess(elements, checked_key, val, 4294 return BuildFastElementAccess(elements, checked_key, val,
4301 map->elements_kind(), is_store); 4295 map->elements_kind(), is_store);
4302 } 4296 }
4303 4297
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4355 todo_external_array = true; 4349 todo_external_array = true;
4356 } 4350 }
4357 num_untransitionable_maps++; 4351 num_untransitionable_maps++;
4358 untransitionable_map = map; 4352 untransitionable_map = map;
4359 } 4353 }
4360 } 4354 }
4361 4355
4362 // If only one map is left after transitioning, handle this case 4356 // If only one map is left after transitioning, handle this case
4363 // monomorphically. 4357 // monomorphically.
4364 if (num_untransitionable_maps == 1) { 4358 if (num_untransitionable_maps == 1) {
4365 HInstruction* instr = AddInstruction(BuildMonomorphicElementAccess( 4359 HInstruction* instr = NULL;
4366 object, key, val, untransitionable_map, is_store)); 4360 if (untransitionable_map->has_slow_elements_kind()) {
4361 instr = AddInstruction(is_store ? BuildStoreKeyedGeneric(object, key, val)
4362 : BuildLoadKeyedGeneric(object, key));
4363 } else {
4364 instr = AddInstruction(BuildMonomorphicElementAccess(
4365 object, key, val, untransitionable_map, is_store));
4366 }
4367 *has_side_effects |= instr->HasObservableSideEffects(); 4367 *has_side_effects |= instr->HasObservableSideEffects();
4368 instr->set_position(position); 4368 instr->set_position(position);
4369 return is_store ? NULL : instr; 4369 return is_store ? NULL : instr;
4370 } 4370 }
4371 4371
4372 AddInstruction(HCheckInstanceType::NewIsSpecObject(object)); 4372 AddInstruction(HCheckInstanceType::NewIsSpecObject(object));
4373 HBasicBlock* join = graph()->CreateBasicBlock(); 4373 HBasicBlock* join = graph()->CreateBasicBlock();
4374 4374
4375 HInstruction* elements_kind_instr = 4375 HInstruction* elements_kind_instr =
4376 AddInstruction(new(zone()) HElementsKind(object)); 4376 AddInstruction(new(zone()) HElementsKind(object));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
4492 HValue* val, 4492 HValue* val,
4493 Expression* expr, 4493 Expression* expr,
4494 int ast_id, 4494 int ast_id,
4495 int position, 4495 int position,
4496 bool is_store, 4496 bool is_store,
4497 bool* has_side_effects) { 4497 bool* has_side_effects) {
4498 ASSERT(!expr->IsPropertyName()); 4498 ASSERT(!expr->IsPropertyName());
4499 HInstruction* instr = NULL; 4499 HInstruction* instr = NULL;
4500 if (expr->IsMonomorphic()) { 4500 if (expr->IsMonomorphic()) {
4501 Handle<Map> map = expr->GetMonomorphicReceiverType(); 4501 Handle<Map> map = expr->GetMonomorphicReceiverType();
4502 AddInstruction(new(zone()) HCheckNonSmi(obj)); 4502 if (map->has_slow_elements_kind()) {
4503 instr = BuildMonomorphicElementAccess(obj, key, val, map, is_store); 4503 instr = is_store ? BuildStoreKeyedGeneric(obj, key, val)
4504 : BuildLoadKeyedGeneric(obj, key);
4505 } else {
4506 AddInstruction(new(zone()) HCheckNonSmi(obj));
4507 instr = BuildMonomorphicElementAccess(obj, key, val, map, is_store);
4508 }
4504 } else if (expr->GetReceiverTypes() != NULL && 4509 } else if (expr->GetReceiverTypes() != NULL &&
4505 !expr->GetReceiverTypes()->is_empty()) { 4510 !expr->GetReceiverTypes()->is_empty()) {
4506 return HandlePolymorphicElementAccess( 4511 return HandlePolymorphicElementAccess(
4507 obj, key, val, expr, ast_id, position, is_store, has_side_effects); 4512 obj, key, val, expr, ast_id, position, is_store, has_side_effects);
4508 } else { 4513 } else {
4509 if (is_store) { 4514 if (is_store) {
4510 instr = BuildStoreKeyedGeneric(obj, key, val); 4515 instr = BuildStoreKeyedGeneric(obj, key, val);
4511 } else { 4516 } else {
4512 instr = BuildLoadKeyedGeneric(obj, key); 4517 instr = BuildLoadKeyedGeneric(obj, key);
4513 } 4518 }
(...skipping 2874 matching lines...) Expand 10 before | Expand all | Expand 10 after
7388 } 7393 }
7389 } 7394 }
7390 7395
7391 #ifdef DEBUG 7396 #ifdef DEBUG
7392 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7397 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7393 if (allocator_ != NULL) allocator_->Verify(); 7398 if (allocator_ != NULL) allocator_->Verify();
7394 #endif 7399 #endif
7395 } 7400 }
7396 7401
7397 } } // namespace v8::internal 7402 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698