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

Side by Side Diff: src/hydrogen.cc

Issue 13693004: Refactoring BuildAllocateElements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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') | no next file » | 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 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 HInstruction* HGraphBuilder::BuildFastArrayLengthLoad(HValue* object, 1238 HInstruction* HGraphBuilder::BuildFastArrayLengthLoad(HValue* object,
1239 HValue* typecheck) { 1239 HValue* typecheck) {
1240 Zone* zone = this->zone(); 1240 Zone* zone = this->zone();
1241 return new (zone) HJSArrayLength(object, typecheck, HType::Smi()); 1241 return new (zone) HJSArrayLength(object, typecheck, HType::Smi());
1242 } 1242 }
1243 1243
1244 1244
1245 HValue* HGraphBuilder::BuildAllocateElements(HValue* context, 1245 HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
1246 ElementsKind kind, 1246 ElementsKind kind,
1247 HValue* capacity) { 1247 HValue* capacity) {
1248 BailoutId ast_id = current_block()->last_environment()->previous_ast_id();
1249 Zone* zone = this->zone(); 1248 Zone* zone = this->zone();
1250 1249
1251 int elements_size = IsFastDoubleElementsKind(kind) 1250 int elements_size = IsFastDoubleElementsKind(kind)
1252 ? kDoubleSize : kPointerSize; 1251 ? kDoubleSize : kPointerSize;
1253 HConstant* elements_size_value = 1252 HConstant* elements_size_value =
1254 new(zone) HConstant(elements_size, Representation::Integer32()); 1253 new(zone) HConstant(elements_size, Representation::Integer32());
1255 AddInstruction(elements_size_value); 1254 AddInstruction(elements_size_value);
1256 HValue* mul = AddInstruction( 1255 HValue* mul = AddInstruction(
1257 HMul::New(zone, context, capacity, elements_size_value)); 1256 HMul::New(zone, context, capacity, elements_size_value));
1258 mul->ChangeRepresentation(Representation::Integer32()); 1257 mul->ChangeRepresentation(Representation::Integer32());
(...skipping 14 matching lines...) Expand all
1273 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); 1272 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
1274 } 1273 }
1275 if (IsFastDoubleElementsKind(kind)) { 1274 if (IsFastDoubleElementsKind(kind)) {
1276 flags = static_cast<HAllocate::Flags>( 1275 flags = static_cast<HAllocate::Flags>(
1277 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); 1276 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED);
1278 } 1277 }
1279 1278
1280 HValue* elements = 1279 HValue* elements =
1281 AddInstruction(new(zone) HAllocate(context, total_size, 1280 AddInstruction(new(zone) HAllocate(context, total_size,
1282 HType::JSArray(), flags)); 1281 HType::JSArray(), flags));
1282 return elements;
1283 }
1283 1284
1285
1286 void HGraphBuilder::BuildInitializeElements(HValue* elements,
1287 ElementsKind kind,
1288 HValue* capacity) {
1289 Zone* zone = this->zone();
1290 BailoutId ast_id = current_block()->last_environment()->previous_ast_id();
1284 Factory* factory = isolate()->factory(); 1291 Factory* factory = isolate()->factory();
1285 Handle<Map> map = IsFastDoubleElementsKind(kind) 1292 Handle<Map> map = IsFastDoubleElementsKind(kind)
1286 ? factory->fixed_double_array_map() 1293 ? factory->fixed_double_array_map()
1287 : factory->fixed_array_map(); 1294 : factory->fixed_array_map();
1288 BuildStoreMap(elements, map, ast_id); 1295 BuildStoreMap(elements, map, ast_id);
1289 1296
1290 Handle<String> fixed_array_length_field_name = factory->length_field_string(); 1297 Handle<String> fixed_array_length_field_name = factory->length_field_string();
1291 HInstruction* store_length = 1298 HInstruction* store_length =
1292 new(zone) HStoreNamedField(elements, fixed_array_length_field_name, 1299 new(zone) HStoreNamedField(elements, fixed_array_length_field_name,
1293 capacity, true, FixedArray::kLengthOffset); 1300 capacity, true, FixedArray::kLengthOffset);
1294 AddInstruction(store_length); 1301 AddInstruction(store_length);
1295 AddSimulate(ast_id, REMOVABLE_SIMULATE); 1302 AddSimulate(ast_id, REMOVABLE_SIMULATE);
1296
1297 return elements;
1298 } 1303 }
1299 1304
1300 1305
1306 HValue* HGraphBuilder::BuildAllocateAndInitializeElements(HValue* context,
1307 ElementsKind kind,
1308 HValue* capacity) {
1309 HValue* new_elements =
1310 BuildAllocateElements(context, kind, capacity);
1311 BuildInitializeElements(new_elements, kind, capacity);
1312 return new_elements;
1313 }
1314
1315
1301 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, 1316 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object,
1302 HValue* map, 1317 HValue* map,
1303 BailoutId id) { 1318 BailoutId id) {
1304 Zone* zone = this->zone(); 1319 Zone* zone = this->zone();
1305 Factory* factory = isolate()->factory(); 1320 Factory* factory = isolate()->factory();
1306 Handle<String> map_field_name = factory->map_field_string(); 1321 Handle<String> map_field_name = factory->map_field_string();
1307 HInstruction* store_map = 1322 HInstruction* store_map =
1308 new(zone) HStoreNamedField(object, map_field_name, map, 1323 new(zone) HStoreNamedField(object, map_field_name, map,
1309 true, JSObject::kMapOffset); 1324 true, JSObject::kMapOffset);
1310 store_map->SetGVNFlag(kChangesMaps); 1325 store_map->SetGVNFlag(kChangesMaps);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 HValue* elements, 1387 HValue* elements,
1373 ElementsKind kind, 1388 ElementsKind kind,
1374 HValue* length, 1389 HValue* length,
1375 HValue* new_capacity) { 1390 HValue* new_capacity) {
1376 Zone* zone = this->zone(); 1391 Zone* zone = this->zone();
1377 HValue* context = environment()->LookupContext(); 1392 HValue* context = environment()->LookupContext();
1378 1393
1379 BuildNewSpaceArrayCheck(new_capacity, kind); 1394 BuildNewSpaceArrayCheck(new_capacity, kind);
1380 1395
1381 HValue* new_elements = 1396 HValue* new_elements =
1382 BuildAllocateElements(context, kind, new_capacity); 1397 BuildAllocateAndInitializeElements(context, kind, new_capacity);
1383 1398
1384 BuildCopyElements(context, elements, kind, 1399 BuildCopyElements(context, elements, kind,
1385 new_elements, kind, 1400 new_elements, kind,
1386 length, new_capacity); 1401 length, new_capacity);
1387 1402
1388 Factory* factory = isolate()->factory(); 1403 Factory* factory = isolate()->factory();
1389 HInstruction* elements_store = AddInstruction(new(zone) HStoreNamedField( 1404 HInstruction* elements_store = AddInstruction(new(zone) HStoreNamedField(
1390 object, 1405 object,
1391 factory->elements_field_string(), 1406 factory->elements_field_string(),
1392 new_elements, true, 1407 new_elements, true,
(...skipping 9896 matching lines...) Expand 10 before | Expand all | Expand 10 after
11289 } 11304 }
11290 } 11305 }
11291 11306
11292 #ifdef DEBUG 11307 #ifdef DEBUG
11293 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11308 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11294 if (allocator_ != NULL) allocator_->Verify(); 11309 if (allocator_ != NULL) allocator_->Verify();
11295 #endif 11310 #endif
11296 } 11311 }
11297 11312
11298 } } // namespace v8::internal 11313 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698