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

Side by Side Diff: src/hydrogen.cc

Issue 12491023: Remove (H|L)JSArrayLength instructions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Cleanup Created 7 years, 8 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.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 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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 AddInstruction(new(zone) HLoadElements(object, mapcheck)); 1158 AddInstruction(new(zone) HLoadElements(object, mapcheck));
1159 if (is_store && (fast_elements || fast_smi_only_elements) && 1159 if (is_store && (fast_elements || fast_smi_only_elements) &&
1160 store_mode != STORE_NO_TRANSITION_HANDLE_COW) { 1160 store_mode != STORE_NO_TRANSITION_HANDLE_COW) {
1161 HCheckMaps* check_cow_map = new(zone) HCheckMaps( 1161 HCheckMaps* check_cow_map = new(zone) HCheckMaps(
1162 elements, isolate()->factory()->fixed_array_map(), zone); 1162 elements, isolate()->factory()->fixed_array_map(), zone);
1163 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); 1163 check_cow_map->ClearGVNFlag(kDependsOnElementsKind);
1164 AddInstruction(check_cow_map); 1164 AddInstruction(check_cow_map);
1165 } 1165 }
1166 HInstruction* length = NULL; 1166 HInstruction* length = NULL;
1167 if (is_js_array) { 1167 if (is_js_array) {
1168 length = AddInstruction(new(zone) HJSArrayLength(object, mapcheck, 1168 length = AddInstruction(
1169 HType::Smi())); 1169 HLoadNamedField::NewArrayLength(zone, object, mapcheck, HType::Smi()));
1170 } else { 1170 } else {
1171 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); 1171 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements));
1172 } 1172 }
1173 HValue* checked_key = NULL; 1173 HValue* checked_key = NULL;
1174 if (IsExternalArrayElementsKind(elements_kind)) { 1174 if (IsExternalArrayElementsKind(elements_kind)) {
1175 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { 1175 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) {
1176 HLoadExternalArrayPointer* external_elements = 1176 HLoadExternalArrayPointer* external_elements =
1177 new(zone) HLoadExternalArrayPointer(elements); 1177 new(zone) HLoadExternalArrayPointer(elements);
1178 AddInstruction(external_elements); 1178 AddInstruction(external_elements);
1179 IfBuilder length_checker(this); 1179 IfBuilder length_checker(this);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 AddInstruction(check_cow_map); 1228 AddInstruction(check_cow_map);
1229 } 1229 }
1230 } 1230 }
1231 } 1231 }
1232 return AddInstruction( 1232 return AddInstruction(
1233 BuildFastElementAccess(elements, checked_key, val, mapcheck, 1233 BuildFastElementAccess(elements, checked_key, val, mapcheck,
1234 elements_kind, is_store, store_mode)); 1234 elements_kind, is_store, store_mode));
1235 } 1235 }
1236 1236
1237 1237
1238 HInstruction* HGraphBuilder::BuildFastArrayLengthLoad(HValue* object,
1239 HValue* typecheck) {
1240 Zone* zone = this->zone();
1241 return new (zone) HJSArrayLength(object, typecheck, HType::Smi());
1242 }
1243
1244
1245 HValue* HGraphBuilder::BuildAllocateElements(HValue* context, 1238 HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
1246 ElementsKind kind, 1239 ElementsKind kind,
1247 HValue* capacity) { 1240 HValue* capacity) {
1248 BailoutId ast_id = current_block()->last_environment()->previous_ast_id(); 1241 BailoutId ast_id = current_block()->last_environment()->previous_ast_id();
1249 Zone* zone = this->zone(); 1242 Zone* zone = this->zone();
1250 1243
1251 int elements_size = IsFastDoubleElementsKind(kind) 1244 int elements_size = IsFastDoubleElementsKind(kind)
1252 ? kDoubleSize : kPointerSize; 1245 ? kDoubleSize : kPointerSize;
1253 HConstant* elements_size_value = 1246 HConstant* elements_size_value =
1254 new(zone) HConstant(elements_size, Representation::Integer32()); 1247 new(zone) HConstant(elements_size, Representation::Integer32());
(...skipping 5163 matching lines...) Expand 10 before | Expand all | Expand 10 after
6418 Handle<String> name) { 6411 Handle<String> name) {
6419 if (!name->Equals(isolate()->heap()->length_string())) return false; 6412 if (!name->Equals(isolate()->heap()->length_string())) return false;
6420 6413
6421 for (int i = 0; i < types->length(); i++) { 6414 for (int i = 0; i < types->length(); i++) {
6422 if (types->at(i)->instance_type() != JS_ARRAY_TYPE) return false; 6415 if (types->at(i)->instance_type() != JS_ARRAY_TYPE) return false;
6423 } 6416 }
6424 6417
6425 AddInstruction(new(zone()) HCheckNonSmi(object)); 6418 AddInstruction(new(zone()) HCheckNonSmi(object));
6426 HInstruction* typecheck = 6419 HInstruction* typecheck =
6427 AddInstruction(HCheckInstanceType::NewIsJSArray(object, zone())); 6420 AddInstruction(HCheckInstanceType::NewIsJSArray(object, zone()));
6428 HInstruction* instr = BuildFastArrayLengthLoad(object, typecheck); 6421 HInstruction* instr =
6422 HLoadNamedField::NewArrayLength(zone(), object, typecheck);
6429 instr->set_position(expr->position()); 6423 instr->set_position(expr->position());
6430 ast_context()->ReturnInstruction(instr, expr->id()); 6424 ast_context()->ReturnInstruction(instr, expr->id());
6431 return true; 6425 return true;
6432 } 6426 }
6433 6427
6434 6428
6435 void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, 6429 void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr,
6436 HValue* object, 6430 HValue* object,
6437 SmallMapList* types, 6431 SmallMapList* types,
6438 Handle<String> name) { 6432 Handle<String> name) {
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
7077 Handle<String> name, 7071 Handle<String> name,
7078 Property* expr, 7072 Property* expr,
7079 Handle<Map> map) { 7073 Handle<Map> map) {
7080 // Handle a load from a known field. 7074 // Handle a load from a known field.
7081 ASSERT(!map->is_dictionary_map()); 7075 ASSERT(!map->is_dictionary_map());
7082 7076
7083 // Handle access to various length properties 7077 // Handle access to various length properties
7084 if (name->Equals(isolate()->heap()->length_string())) { 7078 if (name->Equals(isolate()->heap()->length_string())) {
7085 if (map->instance_type() == JS_ARRAY_TYPE) { 7079 if (map->instance_type() == JS_ARRAY_TYPE) {
7086 AddCheckMapsWithTransitions(object, map); 7080 AddCheckMapsWithTransitions(object, map);
7087 return BuildFastArrayLengthLoad(object, NULL); 7081 return HLoadNamedField::NewArrayLength(zone(), object, object);
7088 } 7082 }
7089 } 7083 }
7090 7084
7091 LookupResult lookup(isolate()); 7085 LookupResult lookup(isolate());
7092 map->LookupDescriptor(NULL, *name, &lookup); 7086 map->LookupDescriptor(NULL, *name, &lookup);
7093 if (lookup.IsField()) { 7087 if (lookup.IsField()) {
7094 AddCheckMap(object, map); 7088 AddCheckMap(object, map);
7095 return BuildLoadNamedField(object, map, &lookup); 7089 return BuildLoadNamedField(object, map, &lookup);
7096 } 7090 }
7097 7091
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
7370 HBasicBlock* if_jsarray = graph()->CreateBasicBlock(); 7364 HBasicBlock* if_jsarray = graph()->CreateBasicBlock();
7371 HBasicBlock* if_fastobject = graph()->CreateBasicBlock(); 7365 HBasicBlock* if_fastobject = graph()->CreateBasicBlock();
7372 HHasInstanceTypeAndBranch* typecheck = 7366 HHasInstanceTypeAndBranch* typecheck =
7373 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE); 7367 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE);
7374 typecheck->SetSuccessorAt(0, if_jsarray); 7368 typecheck->SetSuccessorAt(0, if_jsarray);
7375 typecheck->SetSuccessorAt(1, if_fastobject); 7369 typecheck->SetSuccessorAt(1, if_fastobject);
7376 current_block()->Finish(typecheck); 7370 current_block()->Finish(typecheck);
7377 7371
7378 set_current_block(if_jsarray); 7372 set_current_block(if_jsarray);
7379 HInstruction* length; 7373 HInstruction* length;
7380 length = AddInstruction(new(zone()) HJSArrayLength(object, typecheck, 7374 length = AddInstruction(
7381 HType::Smi())); 7375 HLoadNamedField::NewArrayLength(zone(), object, typecheck,
7376 HType::Smi()));
7382 checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY); 7377 checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY);
7383 access = AddInstruction(BuildFastElementAccess( 7378 access = AddInstruction(BuildFastElementAccess(
7384 elements, checked_key, val, elements_kind_branch, 7379 elements, checked_key, val, elements_kind_branch,
7385 elements_kind, is_store, STANDARD_STORE)); 7380 elements_kind, is_store, STANDARD_STORE));
7386 if (!is_store) { 7381 if (!is_store) {
7387 Push(access); 7382 Push(access);
7388 } 7383 }
7389 7384
7390 *has_side_effects |= access->HasObservableSideEffects(); 7385 *has_side_effects |= access->HasObservableSideEffects();
7391 if (position != -1) { 7386 if (position != -1) {
(...skipping 3887 matching lines...) Expand 10 before | Expand all | Expand 10 after
11279 } 11274 }
11280 } 11275 }
11281 11276
11282 #ifdef DEBUG 11277 #ifdef DEBUG
11283 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11278 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11284 if (allocator_ != NULL) allocator_->Verify(); 11279 if (allocator_ != NULL) allocator_->Verify();
11285 #endif 11280 #endif
11286 } 11281 }
11287 11282
11288 } } // namespace v8::internal 11283 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698