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

Side by Side Diff: src/hydrogen.cc

Issue 149063010: Remake of the load elimination fix made earlier (r18884). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes applied Created 6 years, 10 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 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 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 } 1191 }
1192 1192
1193 1193
1194 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) { 1194 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) {
1195 if (FLAG_native_code_counters && counter->Enabled()) { 1195 if (FLAG_native_code_counters && counter->Enabled()) {
1196 HValue* reference = Add<HConstant>(ExternalReference(counter)); 1196 HValue* reference = Add<HConstant>(ExternalReference(counter));
1197 HValue* old_value = Add<HLoadNamedField>( 1197 HValue* old_value = Add<HLoadNamedField>(
1198 reference, static_cast<HValue*>(NULL), HObjectAccess::ForCounter()); 1198 reference, static_cast<HValue*>(NULL), HObjectAccess::ForCounter());
1199 HValue* new_value = AddUncasted<HAdd>(old_value, graph()->GetConstant1()); 1199 HValue* new_value = AddUncasted<HAdd>(old_value, graph()->GetConstant1());
1200 new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow 1200 new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow
1201 Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(), 1201 Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(),
Toon Verwaest 2014/02/03 18:08:28 join lines
Igor Sheludko 2014/02/03 19:17:58 Done.
1202 new_value, STORE_TO_INITIALIZED_ENTRY); 1202 new_value);
1203 } 1203 }
1204 } 1204 }
1205 1205
1206 1206
1207 void HGraphBuilder::AddSimulate(BailoutId id, 1207 void HGraphBuilder::AddSimulate(BailoutId id,
1208 RemovableSimulate removable) { 1208 RemovableSimulate removable) {
1209 ASSERT(current_block() != NULL); 1209 ASSERT(current_block() != NULL);
1210 ASSERT(!graph()->IsInsideNoSideEffectsScope()); 1210 ASSERT(!graph()->IsInsideNoSideEffectsScope());
1211 current_block()->AddNewSimulate(id, position_, removable); 1211 current_block()->AddNewSimulate(id, position_, removable);
1212 } 1212 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 environment()->Push(new_elements); 1329 environment()->Push(new_elements);
1330 capacity_checker.Else(); 1330 capacity_checker.Else();
1331 1331
1332 environment()->Push(elements); 1332 environment()->Push(elements);
1333 capacity_checker.End(); 1333 capacity_checker.End();
1334 1334
1335 if (is_js_array) { 1335 if (is_js_array) {
1336 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); 1336 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1());
1337 new_length->ClearFlag(HValue::kCanOverflow); 1337 new_length->ClearFlag(HValue::kCanOverflow);
1338 1338
1339 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), 1339 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind),
Toon Verwaest 2014/02/03 18:08:28 join lines
Igor Sheludko 2014/02/03 19:17:58 It will be too long line.
1340 new_length, INITIALIZING_STORE); 1340 new_length);
1341 } 1341 }
1342 1342
1343 if (is_store && kind == FAST_SMI_ELEMENTS) { 1343 if (is_store && kind == FAST_SMI_ELEMENTS) {
1344 HValue* checked_elements = environment()->Top(); 1344 HValue* checked_elements = environment()->Top();
1345 1345
1346 // Write zero to ensure that the new element is initialized with some smi. 1346 // Write zero to ensure that the new element is initialized with some smi.
1347 Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind, 1347 Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind);
1348 INITIALIZING_STORE);
1349 } 1348 }
1350 1349
1351 length_checker.Else(); 1350 length_checker.Else();
1352 Add<HBoundsCheck>(key, length); 1351 Add<HBoundsCheck>(key, length);
1353 1352
1354 environment()->Push(elements); 1353 environment()->Push(elements);
1355 length_checker.End(); 1354 length_checker.End();
1356 1355
1357 return environment()->Pop(); 1356 return environment()->Pop();
1358 } 1357 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 ? Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), 1415 ? Add<HLoadNamedField>(object, static_cast<HValue*>(NULL),
1417 HObjectAccess::ForArrayLength(from_kind)) 1416 HObjectAccess::ForArrayLength(from_kind))
1418 : elements_length; 1417 : elements_length;
1419 1418
1420 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, 1419 BuildGrowElementsCapacity(object, elements, from_kind, to_kind,
1421 array_length, elements_length); 1420 array_length, elements_length);
1422 1421
1423 if_builder.End(); 1422 if_builder.End();
1424 } 1423 }
1425 1424
1426 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map, 1425 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map);
1427 INITIALIZING_STORE);
1428 } 1426 }
1429 1427
1430 1428
1431 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper( 1429 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper(
1432 HValue* elements, 1430 HValue* elements,
1433 HValue* key, 1431 HValue* key,
1434 HValue* hash, 1432 HValue* hash,
1435 HValue* mask, 1433 HValue* mask,
1436 int current_probe) { 1434 int current_probe) {
1437 if (current_probe == kNumberDictionaryProbes) { 1435 if (current_probe == kNumberDictionaryProbes) {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 if_onebyte.Else(); 1876 if_onebyte.Else();
1879 { 1877 {
1880 // We can safely skip the write barrier for storing the map here. 1878 // We can safely skip the write barrier for storing the map here.
1881 Handle<Map> map = isolate()->factory()->cons_string_map(); 1879 Handle<Map> map = isolate()->factory()->cons_string_map();
1882 AddStoreMapConstantNoWriteBarrier(result, map); 1880 AddStoreMapConstantNoWriteBarrier(result, map);
1883 } 1881 }
1884 if_onebyte.End(); 1882 if_onebyte.End();
1885 1883
1886 // Initialize the cons string fields. 1884 // Initialize the cons string fields.
1887 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), 1885 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(),
1888 Add<HConstant>(String::kEmptyHashField), 1886 Add<HConstant>(String::kEmptyHashField));
1889 INITIALIZING_STORE); 1887 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length);
1890 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length, 1888 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left);
1891 INITIALIZING_STORE); 1889 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right);
1892 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left,
1893 INITIALIZING_STORE);
1894 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right,
1895 INITIALIZING_STORE);
1896 1890
1897 // Count the native string addition. 1891 // Count the native string addition.
1898 AddIncrementCounter(isolate()->counters()->string_add_native()); 1892 AddIncrementCounter(isolate()->counters()->string_add_native());
1899 1893
1900 return result; 1894 return result;
1901 } 1895 }
1902 1896
1903 1897
1904 void HGraphBuilder::BuildCopySeqStringChars(HValue* src, 1898 void HGraphBuilder::BuildCopySeqStringChars(HValue* src,
1905 HValue* src_offset, 1899 HValue* src_offset,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 // Allocate the string object. HAllocate does not care whether we pass 2028 // Allocate the string object. HAllocate does not care whether we pass
2035 // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here. 2029 // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here.
2036 HAllocate* result = BuildAllocate( 2030 HAllocate* result = BuildAllocate(
2037 size, HType::String(), STRING_TYPE, allocation_mode); 2031 size, HType::String(), STRING_TYPE, allocation_mode);
2038 2032
2039 // We can safely skip the write barrier for storing map here. 2033 // We can safely skip the write barrier for storing map here.
2040 AddStoreMapNoWriteBarrier(result, map); 2034 AddStoreMapNoWriteBarrier(result, map);
2041 2035
2042 // Initialize the string fields. 2036 // Initialize the string fields.
2043 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), 2037 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(),
2044 Add<HConstant>(String::kEmptyHashField), 2038 Add<HConstant>(String::kEmptyHashField));
2045 INITIALIZING_STORE); 2039 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length);
2046 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length,
2047 INITIALIZING_STORE);
2048 2040
2049 // Copy characters to the result string. 2041 // Copy characters to the result string.
2050 IfBuilder if_twobyte(this); 2042 IfBuilder if_twobyte(this);
2051 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); 2043 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map);
2052 if_twobyte.Then(); 2044 if_twobyte.Then();
2053 { 2045 {
2054 // Copy characters from the left string. 2046 // Copy characters from the left string.
2055 BuildCopySeqStringChars( 2047 BuildCopySeqStringChars(
2056 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, 2048 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING,
2057 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, 2049 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING,
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 2330
2339 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, 2331 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements,
2340 ElementsKind kind, 2332 ElementsKind kind,
2341 HValue* capacity) { 2333 HValue* capacity) {
2342 Factory* factory = isolate()->factory(); 2334 Factory* factory = isolate()->factory();
2343 Handle<Map> map = IsFastDoubleElementsKind(kind) 2335 Handle<Map> map = IsFastDoubleElementsKind(kind)
2344 ? factory->fixed_double_array_map() 2336 ? factory->fixed_double_array_map()
2345 : factory->fixed_array_map(); 2337 : factory->fixed_array_map();
2346 2338
2347 AddStoreMapConstant(elements, map); 2339 AddStoreMapConstant(elements, map);
2348 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), 2340 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(),
Toon Verwaest 2014/02/03 18:08:28 join lines
Igor Sheludko 2014/02/03 19:17:58 Too long line.
2349 capacity, INITIALIZING_STORE); 2341 capacity);
2350 } 2342 }
2351 2343
2352 2344
2353 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( 2345 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader(
2354 ElementsKind kind, 2346 ElementsKind kind,
2355 HValue* capacity) { 2347 HValue* capacity) {
2356 // The HForceRepresentation is to prevent possible deopt on int-smi 2348 // The HForceRepresentation is to prevent possible deopt on int-smi
2357 // conversion after allocation but before the new object fields are set. 2349 // conversion after allocation but before the new object fields are set.
2358 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); 2350 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi());
2359 HValue* new_elements = BuildAllocateElements(kind, capacity); 2351 HValue* new_elements = BuildAllocateElements(kind, capacity);
2360 BuildInitializeElementsHeader(new_elements, kind, capacity); 2352 BuildInitializeElementsHeader(new_elements, kind, capacity);
2361 return new_elements; 2353 return new_elements;
2362 } 2354 }
2363 2355
2364 2356
2365 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, 2357 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
2366 HValue* array_map, 2358 HValue* array_map,
2367 AllocationSiteMode mode, 2359 AllocationSiteMode mode,
2368 ElementsKind elements_kind, 2360 ElementsKind elements_kind,
2369 HValue* allocation_site_payload, 2361 HValue* allocation_site_payload,
2370 HValue* length_field) { 2362 HValue* length_field) {
2371 2363
2372 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map, 2364 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map);
2373 INITIALIZING_STORE);
2374 2365
2375 HConstant* empty_fixed_array = 2366 HConstant* empty_fixed_array =
2376 Add<HConstant>(isolate()->factory()->empty_fixed_array()); 2367 Add<HConstant>(isolate()->factory()->empty_fixed_array());
2377 2368
2378 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 2369 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
2379 Add<HStoreNamedField>(array, access, empty_fixed_array, INITIALIZING_STORE); 2370 Add<HStoreNamedField>(array, access, empty_fixed_array);
2380 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), 2371 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind),
2381 length_field, INITIALIZING_STORE); 2372 length_field);
2382 2373
2383 if (mode == TRACK_ALLOCATION_SITE) { 2374 if (mode == TRACK_ALLOCATION_SITE) {
2384 BuildCreateAllocationMemento( 2375 BuildCreateAllocationMemento(
2385 array, Add<HConstant>(JSArray::kSize), allocation_site_payload); 2376 array, Add<HConstant>(JSArray::kSize), allocation_site_payload);
2386 } 2377 }
2387 2378
2388 int elements_location = JSArray::kSize; 2379 int elements_location = JSArray::kSize;
2389 if (mode == TRACK_ALLOCATION_SITE) { 2380 if (mode == TRACK_ALLOCATION_SITE) {
2390 elements_location += AllocationMemento::kSize; 2381 elements_location += AllocationMemento::kSize;
2391 } 2382 }
2392 2383
2393 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>( 2384 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>(
2394 array, Add<HConstant>(elements_location)); 2385 array, Add<HConstant>(elements_location));
2395 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements, 2386 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements);
2396 INITIALIZING_STORE);
2397 return elements; 2387 return elements;
2398 } 2388 }
2399 2389
2400 2390
2401 HInstruction* HGraphBuilder::AddElementAccess( 2391 HInstruction* HGraphBuilder::AddElementAccess(
2402 HValue* elements, 2392 HValue* elements,
2403 HValue* checked_key, 2393 HValue* checked_key,
2404 HValue* val, 2394 HValue* val,
2405 HValue* dependency, 2395 HValue* dependency,
2406 ElementsKind elements_kind, 2396 ElementsKind elements_kind,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2477 HValue* new_capacity) { 2467 HValue* new_capacity) {
2478 BuildNewSpaceArrayCheck(new_capacity, new_kind); 2468 BuildNewSpaceArrayCheck(new_capacity, new_kind);
2479 2469
2480 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( 2470 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader(
2481 new_kind, new_capacity); 2471 new_kind, new_capacity);
2482 2472
2483 BuildCopyElements(elements, kind, 2473 BuildCopyElements(elements, kind,
2484 new_elements, new_kind, 2474 new_elements, new_kind,
2485 length, new_capacity); 2475 length, new_capacity);
2486 2476
2487 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 2477 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
Toon Verwaest 2014/02/03 18:08:28 join lines
Igor Sheludko 2014/02/03 19:17:58 Too long line.
2488 new_elements, INITIALIZING_STORE); 2478 new_elements);
2489 2479
2490 return new_elements; 2480 return new_elements;
2491 } 2481 }
2492 2482
2493 2483
2494 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, 2484 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements,
2495 ElementsKind elements_kind, 2485 ElementsKind elements_kind,
2496 HValue* from, 2486 HValue* from,
2497 HValue* to) { 2487 HValue* to) {
2498 // Fast elements kinds need to be initialized in case statements below cause 2488 // Fast elements kinds need to be initialized in case statements below cause
(...skipping 20 matching lines...) Expand all
2519 2509
2520 // Since we're about to store a hole value, the store instruction below must 2510 // Since we're about to store a hole value, the store instruction below must
2521 // assume an elements kind that supports heap object values. 2511 // assume an elements kind that supports heap object values.
2522 if (IsFastSmiOrObjectElementsKind(elements_kind)) { 2512 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
2523 elements_kind = FAST_HOLEY_ELEMENTS; 2513 elements_kind = FAST_HOLEY_ELEMENTS;
2524 } 2514 }
2525 2515
2526 if (initial_capacity >= 0) { 2516 if (initial_capacity >= 0) {
2527 for (int i = 0; i < initial_capacity; i++) { 2517 for (int i = 0; i < initial_capacity; i++) {
2528 HInstruction* key = Add<HConstant>(i); 2518 HInstruction* key = Add<HConstant>(i);
2529 Add<HStoreKeyed>(elements, key, hole, elements_kind, 2519 Add<HStoreKeyed>(elements, key, hole, elements_kind);
2530 PREINITIALIZING_STORE);
2531 } 2520 }
2532 } else { 2521 } else {
2533 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); 2522 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement);
2534 2523
2535 HValue* key = builder.BeginBody(from, to, Token::LT); 2524 HValue* key = builder.BeginBody(from, to, Token::LT);
2536 2525
2537 Add<HStoreKeyed>(elements, key, hole, elements_kind, PREINITIALIZING_STORE); 2526 Add<HStoreKeyed>(elements, key, hole, elements_kind);
2538 2527
2539 builder.EndBody(); 2528 builder.EndBody();
2540 } 2529 }
2541 } 2530 }
2542 2531
2543 2532
2544 void HGraphBuilder::BuildCopyElements(HValue* from_elements, 2533 void HGraphBuilder::BuildCopyElements(HValue* from_elements,
2545 ElementsKind from_elements_kind, 2534 ElementsKind from_elements_kind,
2546 HValue* to_elements, 2535 HValue* to_elements,
2547 ElementsKind to_elements_kind, 2536 ElementsKind to_elements_kind,
(...skipping 25 matching lines...) Expand all
2573 ? FAST_HOLEY_ELEMENTS : to_elements_kind; 2562 ? FAST_HOLEY_ELEMENTS : to_elements_kind;
2574 2563
2575 if (IsHoleyElementsKind(from_elements_kind) && 2564 if (IsHoleyElementsKind(from_elements_kind) &&
2576 from_elements_kind != to_elements_kind) { 2565 from_elements_kind != to_elements_kind) {
2577 IfBuilder if_hole(this); 2566 IfBuilder if_hole(this);
2578 if_hole.If<HCompareHoleAndBranch>(element); 2567 if_hole.If<HCompareHoleAndBranch>(element);
2579 if_hole.Then(); 2568 if_hole.Then();
2580 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind) 2569 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind)
2581 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double()) 2570 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double())
2582 : graph()->GetConstantHole(); 2571 : graph()->GetConstantHole();
2583 Add<HStoreKeyed>(to_elements, key, hole_constant, kind, 2572 Add<HStoreKeyed>(to_elements, key, hole_constant, kind);
2584 PREINITIALIZING_STORE);
2585 if_hole.Else(); 2573 if_hole.Else();
2586 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind, 2574 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind);
2587 INITIALIZING_STORE);
2588 store->SetFlag(HValue::kAllowUndefinedAsNaN); 2575 store->SetFlag(HValue::kAllowUndefinedAsNaN);
2589 if_hole.End(); 2576 if_hole.End();
2590 } else { 2577 } else {
2591 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind, 2578 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind);
2592 INITIALIZING_STORE);
2593 store->SetFlag(HValue::kAllowUndefinedAsNaN); 2579 store->SetFlag(HValue::kAllowUndefinedAsNaN);
2594 } 2580 }
2595 2581
2596 builder.EndBody(); 2582 builder.EndBody();
2597 2583
2598 if (!pre_fill_with_holes && length != capacity) { 2584 if (!pre_fill_with_holes && length != capacity) {
2599 // Fill unused capacity with the hole. 2585 // Fill unused capacity with the hole.
2600 BuildFillElementsWithHole(to_elements, to_elements_kind, 2586 BuildFillElementsWithHole(to_elements, to_elements_kind,
2601 key, capacity); 2587 key, capacity);
2602 } 2588 }
(...skipping 18 matching lines...) Expand all
2621 HType::JSObject(), 2607 HType::JSObject(),
2622 NOT_TENURED, 2608 NOT_TENURED,
2623 JS_OBJECT_TYPE); 2609 JS_OBJECT_TYPE);
2624 2610
2625 // Copy the JS array part. 2611 // Copy the JS array part.
2626 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { 2612 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
2627 if ((i != JSArray::kElementsOffset) || (length == 0)) { 2613 if ((i != JSArray::kElementsOffset) || (length == 0)) {
2628 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); 2614 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i);
2629 Add<HStoreNamedField>( 2615 Add<HStoreNamedField>(
2630 object, access, Add<HLoadNamedField>( 2616 object, access, Add<HLoadNamedField>(
2631 boilerplate, static_cast<HValue*>(NULL), access), 2617 boilerplate, static_cast<HValue*>(NULL), access));
2632 INITIALIZING_STORE);
2633 } 2618 }
2634 } 2619 }
2635 2620
2636 // Create an allocation site info if requested. 2621 // Create an allocation site info if requested.
2637 if (mode == TRACK_ALLOCATION_SITE) { 2622 if (mode == TRACK_ALLOCATION_SITE) {
2638 BuildCreateAllocationMemento( 2623 BuildCreateAllocationMemento(
2639 object, Add<HConstant>(JSArray::kSize), allocation_site); 2624 object, Add<HConstant>(JSArray::kSize), allocation_site);
2640 } 2625 }
2641 2626
2642 if (length > 0) { 2627 if (length > 0) {
2643 HValue* boilerplate_elements = AddLoadElements(boilerplate); 2628 HValue* boilerplate_elements = AddLoadElements(boilerplate);
2644 HValue* object_elements; 2629 HValue* object_elements;
2645 if (IsFastDoubleElementsKind(kind)) { 2630 if (IsFastDoubleElementsKind(kind)) {
2646 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); 2631 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length));
2647 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), 2632 object_elements = Add<HAllocate>(elems_size, HType::JSArray(),
2648 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); 2633 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE);
2649 } else { 2634 } else {
2650 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); 2635 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length));
2651 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), 2636 object_elements = Add<HAllocate>(elems_size, HType::JSArray(),
2652 NOT_TENURED, FIXED_ARRAY_TYPE); 2637 NOT_TENURED, FIXED_ARRAY_TYPE);
2653 } 2638 }
2654 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 2639 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
2655 object_elements, INITIALIZING_STORE); 2640 object_elements);
2656 2641
2657 // Copy the elements array header. 2642 // Copy the elements array header.
2658 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { 2643 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) {
2659 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); 2644 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i);
2660 Add<HStoreNamedField>( 2645 Add<HStoreNamedField>(
2661 object_elements, access, Add<HLoadNamedField>( 2646 object_elements, access, Add<HLoadNamedField>(
2662 boilerplate_elements, static_cast<HValue*>(NULL), access), 2647 boilerplate_elements, static_cast<HValue*>(NULL), access));
2663 INITIALIZING_STORE);
2664 } 2648 }
2665 2649
2666 // Copy the elements array contents. 2650 // Copy the elements array contents.
2667 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold 2651 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold
2668 // copying loops with constant length up to a given boundary and use this 2652 // copying loops with constant length up to a given boundary and use this
2669 // helper here instead. 2653 // helper here instead.
2670 for (int i = 0; i < length; i++) { 2654 for (int i = 0; i < length; i++) {
2671 HValue* key_constant = Add<HConstant>(i); 2655 HValue* key_constant = Add<HConstant>(i);
2672 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, 2656 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant,
2673 static_cast<HValue*>(NULL), kind); 2657 static_cast<HValue*>(NULL), kind);
2674 Add<HStoreKeyed>(object_elements, key_constant, value, kind, 2658 Add<HStoreKeyed>(object_elements, key_constant, value, kind);
2675 INITIALIZING_STORE);
2676 } 2659 }
2677 } 2660 }
2678 2661
2679 return object; 2662 return object;
2680 } 2663 }
2681 2664
2682 2665
2683 void HGraphBuilder::BuildCompareNil( 2666 void HGraphBuilder::BuildCompareNil(
2684 HValue* value, 2667 HValue* value,
2685 Type* type, 2668 Type* type,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 void HGraphBuilder::BuildCreateAllocationMemento( 2718 void HGraphBuilder::BuildCreateAllocationMemento(
2736 HValue* previous_object, 2719 HValue* previous_object,
2737 HValue* previous_object_size, 2720 HValue* previous_object_size,
2738 HValue* allocation_site) { 2721 HValue* allocation_site) {
2739 ASSERT(allocation_site != NULL); 2722 ASSERT(allocation_site != NULL);
2740 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( 2723 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>(
2741 previous_object, previous_object_size); 2724 previous_object, previous_object_size);
2742 AddStoreMapConstant( 2725 AddStoreMapConstant(
2743 allocation_memento, isolate()->factory()->allocation_memento_map()); 2726 allocation_memento, isolate()->factory()->allocation_memento_map());
2744 Add<HStoreNamedField>( 2727 Add<HStoreNamedField>(
2745 allocation_memento, HObjectAccess::ForAllocationMementoSite(), 2728 allocation_memento,
2746 allocation_site, INITIALIZING_STORE); 2729 HObjectAccess::ForAllocationMementoSite(),
2730 allocation_site);
2747 if (FLAG_allocation_site_pretenuring) { 2731 if (FLAG_allocation_site_pretenuring) {
2748 HValue* memento_create_count = Add<HLoadNamedField>( 2732 HValue* memento_create_count = Add<HLoadNamedField>(
2749 allocation_site, static_cast<HValue*>(NULL), 2733 allocation_site, static_cast<HValue*>(NULL),
2750 HObjectAccess::ForAllocationSiteOffset( 2734 HObjectAccess::ForAllocationSiteOffset(
2751 AllocationSite::kPretenureCreateCountOffset)); 2735 AllocationSite::kPretenureCreateCountOffset));
2752 memento_create_count = AddUncasted<HAdd>( 2736 memento_create_count = AddUncasted<HAdd>(
2753 memento_create_count, graph()->GetConstant1()); 2737 memento_create_count, graph()->GetConstant1());
2754 // This smi value is reset to zero after every gc, overflow isn't a problem 2738 // This smi value is reset to zero after every gc, overflow isn't a problem
2755 // since the counter is bounded by the new space size. 2739 // since the counter is bounded by the new space size.
2756 memento_create_count->ClearFlag(HValue::kCanOverflow); 2740 memento_create_count->ClearFlag(HValue::kCanOverflow);
2757 HStoreNamedField* store = Add<HStoreNamedField>( 2741 HStoreNamedField* store = Add<HStoreNamedField>(
2758 allocation_site, HObjectAccess::ForAllocationSiteOffset( 2742 allocation_site, HObjectAccess::ForAllocationSiteOffset(
2759 AllocationSite::kPretenureCreateCountOffset), memento_create_count, 2743 AllocationSite::kPretenureCreateCountOffset), memento_create_count);
2760 INITIALIZING_STORE);
2761 // No write barrier needed to store a smi. 2744 // No write barrier needed to store a smi.
2762 store->SkipWriteBarrier(); 2745 store->SkipWriteBarrier();
2763 } 2746 }
2764 } 2747 }
2765 2748
2766 2749
2767 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { 2750 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) {
2768 // Get the global context, then the native context 2751 // Get the global context, then the native context
2769 HInstruction* context = 2752 HInstruction* context =
2770 Add<HLoadNamedField>(closure, static_cast<HValue*>(NULL), 2753 Add<HLoadNamedField>(closure, static_cast<HValue*>(NULL),
2771 HObjectAccess::ForFunctionContextPointer()); 2754 HObjectAccess::ForFunctionContextPointer());
2772 HInstruction* global_object = Add<HLoadNamedField>( 2755 HInstruction* global_object = Add<HLoadNamedField>(
2773 context, static_cast<HValue*>(NULL), 2756 context, static_cast<HValue*>(NULL),
2774 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 2757 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2775 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 2758 HObjectAccess access = HObjectAccess::ForObservableJSObjectPropertyAt(
2776 GlobalObject::kNativeContextOffset); 2759 GlobalObject::kNativeContextOffset);
2777 return Add<HLoadNamedField>( 2760 return Add<HLoadNamedField>(
2778 global_object, static_cast<HValue*>(NULL), access); 2761 global_object, static_cast<HValue*>(NULL), access);
2779 } 2762 }
2780 2763
2781 2764
2782 HInstruction* HGraphBuilder::BuildGetNativeContext() { 2765 HInstruction* HGraphBuilder::BuildGetNativeContext() {
2783 // Get the global context, then the native context 2766 // Get the global context, then the native context
2784 HValue* global_object = Add<HLoadNamedField>( 2767 HValue* global_object = Add<HLoadNamedField>(
2785 context(), static_cast<HValue*>(NULL), 2768 context(), static_cast<HValue*>(NULL),
2786 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 2769 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2787 return Add<HLoadNamedField>( 2770 return Add<HLoadNamedField>(
2788 global_object, static_cast<HValue*>(NULL), 2771 global_object, static_cast<HValue*>(NULL),
2789 HObjectAccess::ForJSObjectOffset(GlobalObject::kNativeContextOffset)); 2772 HObjectAccess::ForObservableJSObjectPropertyAt(
2773 GlobalObject::kNativeContextOffset));
2790 } 2774 }
2791 2775
2792 2776
2793 HInstruction* HGraphBuilder::BuildGetArrayFunction() { 2777 HInstruction* HGraphBuilder::BuildGetArrayFunction() {
2794 HInstruction* native_context = BuildGetNativeContext(); 2778 HInstruction* native_context = BuildGetNativeContext();
2795 HInstruction* index = 2779 HInstruction* index =
2796 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX)); 2780 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX));
2797 return Add<HLoadKeyed>( 2781 return Add<HLoadKeyed>(
2798 native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS); 2782 native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS);
2799 } 2783 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 graph()->GetConstant0(), capacity); 2954 graph()->GetConstant0(), capacity);
2971 } 2955 }
2972 2956
2973 return new_object; 2957 return new_object;
2974 } 2958 }
2975 2959
2976 2960
2977 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, 2961 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object,
2978 Handle<Map> map) { 2962 Handle<Map> map) {
2979 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), 2963 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
2980 Add<HConstant>(map), INITIALIZING_STORE); 2964 Add<HConstant>(map));
2981 } 2965 }
2982 2966
2983 2967
2984 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { 2968 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) {
2985 HValue* global_object = Add<HLoadNamedField>( 2969 HValue* global_object = Add<HLoadNamedField>(
2986 context(), static_cast<HValue*>(NULL), 2970 context(), static_cast<HValue*>(NULL),
2987 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 2971 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2988 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 2972 HObjectAccess access = HObjectAccess::ForObservableJSObjectPropertyAt(
2989 GlobalObject::kBuiltinsOffset); 2973 GlobalObject::kBuiltinsOffset);
2990 HValue* builtins = Add<HLoadNamedField>( 2974 HValue* builtins = Add<HLoadNamedField>(
2991 global_object, static_cast<HValue*>(NULL), access); 2975 global_object, static_cast<HValue*>(NULL), access);
2992 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset( 2976 HObjectAccess function_access =
2993 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); 2977 HObjectAccess::ForObservableJSObjectPropertyAt(
2978 JSBuiltinsObject::OffsetOfFunctionWithId(builtin));
2994 return Add<HLoadNamedField>( 2979 return Add<HLoadNamedField>(
2995 builtins, static_cast<HValue*>(NULL), function_access); 2980 builtins, static_cast<HValue*>(NULL), function_access);
2996 } 2981 }
2997 2982
2998 2983
2999 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) 2984 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
3000 : HGraphBuilder(info), 2985 : HGraphBuilder(info),
3001 function_state_(NULL), 2986 function_state_(NULL),
3002 initial_function_state_(this, info, NORMAL_RETURN), 2987 initial_function_state_(this, info, NORMAL_RETURN),
3003 ast_context_(NULL), 2988 ast_context_(NULL),
(...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after
5302 HValue* key = Add<HConstant>(i); 5287 HValue* key = Add<HConstant>(i);
5303 5288
5304 switch (boilerplate_elements_kind) { 5289 switch (boilerplate_elements_kind) {
5305 case FAST_SMI_ELEMENTS: 5290 case FAST_SMI_ELEMENTS:
5306 case FAST_HOLEY_SMI_ELEMENTS: 5291 case FAST_HOLEY_SMI_ELEMENTS:
5307 case FAST_ELEMENTS: 5292 case FAST_ELEMENTS:
5308 case FAST_HOLEY_ELEMENTS: 5293 case FAST_HOLEY_ELEMENTS:
5309 case FAST_DOUBLE_ELEMENTS: 5294 case FAST_DOUBLE_ELEMENTS:
5310 case FAST_HOLEY_DOUBLE_ELEMENTS: { 5295 case FAST_HOLEY_DOUBLE_ELEMENTS: {
5311 HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, 5296 HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value,
5312 boilerplate_elements_kind, 5297 boilerplate_elements_kind);
5313 INITIALIZING_STORE);
5314 instr->SetUninitialized(uninitialized); 5298 instr->SetUninitialized(uninitialized);
5315 break; 5299 break;
5316 } 5300 }
5317 default: 5301 default:
5318 UNREACHABLE(); 5302 UNREACHABLE();
5319 break; 5303 break;
5320 } 5304 }
5321 5305
5322 Add<HSimulate>(expr->GetIdForElement(i)); 5306 Add<HSimulate>(expr->GetIdForElement(i));
5323 } 5307 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5384 5368
5385 PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ? 5369 PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ?
5386 isolate()->heap()->GetPretenureMode() : NOT_TENURED; 5370 isolate()->heap()->GetPretenureMode() : NOT_TENURED;
5387 5371
5388 HInstruction* heap_number = Add<HAllocate>(heap_number_size, 5372 HInstruction* heap_number = Add<HAllocate>(heap_number_size,
5389 HType::HeapNumber(), 5373 HType::HeapNumber(),
5390 pretenure_flag, 5374 pretenure_flag,
5391 HEAP_NUMBER_TYPE); 5375 HEAP_NUMBER_TYPE);
5392 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map()); 5376 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map());
5393 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), 5377 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(),
5394 value, INITIALIZING_STORE); 5378 value);
5395 instr = New<HStoreNamedField>(checked_object->ActualValue(), 5379 instr = New<HStoreNamedField>(checked_object->ActualValue(),
5396 heap_number_access, 5380 heap_number_access,
5397 heap_number, INITIALIZING_STORE); 5381 heap_number);
5398 } else { 5382 } else {
5399 // Already holds a HeapNumber; load the box and write its value field. 5383 // Already holds a HeapNumber; load the box and write its value field.
5400 HInstruction* heap_number = Add<HLoadNamedField>( 5384 HInstruction* heap_number = Add<HLoadNamedField>(
5401 checked_object, static_cast<HValue*>(NULL), heap_number_access); 5385 checked_object, static_cast<HValue*>(NULL), heap_number_access);
5402 heap_number->set_type(HType::HeapNumber()); 5386 heap_number->set_type(HType::HeapNumber());
5403 instr = New<HStoreNamedField>(heap_number, 5387 instr = New<HStoreNamedField>(heap_number,
5404 HObjectAccess::ForHeapNumberValue(), 5388 HObjectAccess::ForHeapNumberValue(),
5405 value, STORE_TO_INITIALIZED_ENTRY); 5389 value);
5406 } 5390 }
5407 } else { 5391 } else {
5408 // This is a normal store. 5392 // This is a normal store.
5409 instr = New<HStoreNamedField>( 5393 instr = New<HStoreNamedField>(
5410 checked_object->ActualValue(), field_access, value, 5394 checked_object->ActualValue(), field_access, value,
5411 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); 5395 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY);
5412 } 5396 }
5413 5397
5414 if (transition_to_field) { 5398 if (transition_to_field) {
5415 Handle<Map> transition(lookup->GetTransitionMapFromMap(*map)); 5399 Handle<Map> transition(lookup->GetTransitionMapFromMap(*map));
(...skipping 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after
8028 } 8012 }
8029 } 8013 }
8030 8014
8031 8015
8032 HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function, 8016 HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function,
8033 Handle<JSFunction> target) { 8017 Handle<JSFunction> target) {
8034 SharedFunctionInfo* shared = target->shared(); 8018 SharedFunctionInfo* shared = target->shared();
8035 if (shared->is_classic_mode() && !shared->native()) { 8019 if (shared->is_classic_mode() && !shared->native()) {
8036 HValue* context = Add<HLoadNamedField>( 8020 HValue* context = Add<HLoadNamedField>(
8037 function, static_cast<HValue*>(NULL), 8021 function, static_cast<HValue*>(NULL),
8038 HObjectAccess::ForJSObjectOffset(JSFunction::kContextOffset)); 8022 HObjectAccess::ForMapAndOffset(handle(target->map()),
8023 JSFunction::kContextOffset));
8039 HValue* global_object = Add<HLoadNamedField>( 8024 HValue* global_object = Add<HLoadNamedField>(
8040 context, static_cast<HValue*>(NULL), 8025 context, static_cast<HValue*>(NULL),
8041 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 8026 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
8042 return Add<HLoadNamedField>( 8027 return Add<HLoadNamedField>(
8043 global_object, static_cast<HValue*>(NULL), 8028 global_object, static_cast<HValue*>(NULL),
8044 HObjectAccess::ForJSObjectOffset( 8029 HObjectAccess::ForMapAndOffset(
8030 handle(target->context()->global_object()->map()),
8045 GlobalObject::kGlobalReceiverOffset)); 8031 GlobalObject::kGlobalReceiverOffset));
8046 } 8032 }
8047 return graph()->GetConstantUndefined(); 8033 return graph()->GetConstantUndefined();
8048 } 8034 }
8049 8035
8050 8036
8051 void HOptimizedGraphBuilder::VisitCall(Call* expr) { 8037 void HOptimizedGraphBuilder::VisitCall(Call* expr) {
8052 ASSERT(!HasStackOverflow()); 8038 ASSERT(!HasStackOverflow());
8053 ASSERT(current_block() != NULL); 8039 ASSERT(current_block() != NULL);
8054 ASSERT(current_block()->HasPredecessor()); 8040 ASSERT(current_block()->HasPredecessor());
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
8315 // TODO(mvstanton): If all the arguments are constants in smi range, then 8301 // TODO(mvstanton): If all the arguments are constants in smi range, then
8316 // we could set fill_with_hole to false and save a few instructions. 8302 // we could set fill_with_hole to false and save a few instructions.
8317 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind) 8303 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind)
8318 ? JSArrayBuilder::FILL_WITH_HOLE 8304 ? JSArrayBuilder::FILL_WITH_HOLE
8319 : JSArrayBuilder::DONT_FILL_WITH_HOLE; 8305 : JSArrayBuilder::DONT_FILL_WITH_HOLE;
8320 new_object = array_builder.AllocateArray(length, length, fill_mode); 8306 new_object = array_builder.AllocateArray(length, length, fill_mode);
8321 HValue* elements = array_builder.GetElementsLocation(); 8307 HValue* elements = array_builder.GetElementsLocation();
8322 for (int i = 0; i < argument_count; i++) { 8308 for (int i = 0; i < argument_count; i++) {
8323 HValue* value = environment()->ExpressionStackAt(argument_count - i - 1); 8309 HValue* value = environment()->ExpressionStackAt(argument_count - i - 1);
8324 HValue* constant_i = Add<HConstant>(i); 8310 HValue* constant_i = Add<HConstant>(i);
8325 Add<HStoreKeyed>(elements, constant_i, value, kind, INITIALIZING_STORE); 8311 Add<HStoreKeyed>(elements, constant_i, value, kind);
8326 } 8312 }
8327 } 8313 }
8328 8314
8329 Drop(argument_count + 1); // drop constructor and args. 8315 Drop(argument_count + 1); // drop constructor and args.
8330 ast_context()->ReturnValue(new_object); 8316 ast_context()->ReturnValue(new_object);
8331 } 8317 }
8332 8318
8333 8319
8334 // Checks whether allocation using the given constructor can be inlined. 8320 // Checks whether allocation using the given constructor can be inlined.
8335 static bool IsAllocationInlineable(Handle<JSFunction> constructor) { 8321 static bool IsAllocationInlineable(Handle<JSFunction> constructor) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
8424 isolate()->heap()->GetPretenureMode() : NOT_TENURED; 8410 isolate()->heap()->GetPretenureMode() : NOT_TENURED;
8425 HAllocate* receiver = 8411 HAllocate* receiver =
8426 Add<HAllocate>(size_in_bytes, HType::JSObject(), pretenure_flag, 8412 Add<HAllocate>(size_in_bytes, HType::JSObject(), pretenure_flag,
8427 JS_OBJECT_TYPE); 8413 JS_OBJECT_TYPE);
8428 receiver->set_known_initial_map(initial_map); 8414 receiver->set_known_initial_map(initial_map);
8429 8415
8430 // Load the initial map from the constructor. 8416 // Load the initial map from the constructor.
8431 HValue* constructor_value = Add<HConstant>(constructor); 8417 HValue* constructor_value = Add<HConstant>(constructor);
8432 HValue* initial_map_value = 8418 HValue* initial_map_value =
8433 Add<HLoadNamedField>(constructor_value, static_cast<HValue*>(NULL), 8419 Add<HLoadNamedField>(constructor_value, static_cast<HValue*>(NULL),
8434 HObjectAccess::ForJSObjectOffset( 8420 HObjectAccess::ForMapAndOffset(
8421 handle(constructor->map()),
8435 JSFunction::kPrototypeOrInitialMapOffset)); 8422 JSFunction::kPrototypeOrInitialMapOffset));
8436 8423
8437 // Initialize map and fields of the newly allocated object. 8424 // Initialize map and fields of the newly allocated object.
8438 { NoObservableSideEffectsScope no_effects(this); 8425 { NoObservableSideEffectsScope no_effects(this);
8439 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); 8426 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
8440 Add<HStoreNamedField>(receiver, 8427 Add<HStoreNamedField>(receiver,
8441 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), 8428 HObjectAccess::ForMapAndOffset(initial_map, JSObject::kMapOffset),
8442 initial_map_value, INITIALIZING_STORE); 8429 initial_map_value);
8443 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); 8430 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array());
8444 Add<HStoreNamedField>(receiver, 8431 Add<HStoreNamedField>(receiver,
8445 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), 8432 HObjectAccess::ForMapAndOffset(initial_map,
8446 empty_fixed_array, INITIALIZING_STORE); 8433 JSObject::kPropertiesOffset),
8434 empty_fixed_array);
8447 Add<HStoreNamedField>(receiver, 8435 Add<HStoreNamedField>(receiver,
8448 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), 8436 HObjectAccess::ForMapAndOffset(initial_map,
8449 empty_fixed_array, INITIALIZING_STORE); 8437 JSObject::kElementsOffset),
8438 empty_fixed_array);
8450 if (initial_map->inobject_properties() != 0) { 8439 if (initial_map->inobject_properties() != 0) {
8451 HConstant* undefined = graph()->GetConstantUndefined(); 8440 HConstant* undefined = graph()->GetConstantUndefined();
8452 for (int i = 0; i < initial_map->inobject_properties(); i++) { 8441 for (int i = 0; i < initial_map->inobject_properties(); i++) {
8453 int property_offset = JSObject::kHeaderSize + i * kPointerSize; 8442 int property_offset = initial_map->GetInObjectPropertyOffset(i);
8454 Add<HStoreNamedField>(receiver, 8443 Add<HStoreNamedField>(receiver,
8455 HObjectAccess::ForJSObjectOffset(property_offset), 8444 HObjectAccess::ForMapAndOffset(initial_map, property_offset),
8456 undefined, PREINITIALIZING_STORE); 8445 undefined);
8457 } 8446 }
8458 } 8447 }
8459 } 8448 }
8460 8449
8461 // Replace the constructor function with a newly allocated receiver using 8450 // Replace the constructor function with a newly allocated receiver using
8462 // the index of the receiver from the top of the expression stack. 8451 // the index of the receiver from the top of the expression stack.
8463 const int receiver_index = argument_count - 1; 8452 const int receiver_index = argument_count - 1;
8464 ASSERT(environment()->ExpressionStackAt(receiver_index) == function); 8453 ASSERT(environment()->ExpressionStackAt(receiver_index) == function);
8465 environment()->SetExpressionStackAt(receiver_index, receiver); 8454 environment()->SetExpressionStackAt(receiver_index, receiver);
8466 8455
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
8530 void HGraphBuilder::BuildArrayBufferViewInitialization( 8519 void HGraphBuilder::BuildArrayBufferViewInitialization(
8531 HValue* obj, 8520 HValue* obj,
8532 HValue* buffer, 8521 HValue* buffer,
8533 HValue* byte_offset, 8522 HValue* byte_offset,
8534 HValue* byte_length) { 8523 HValue* byte_length) {
8535 8524
8536 for (int offset = ViewClass::kSize; 8525 for (int offset = ViewClass::kSize;
8537 offset < ViewClass::kSizeWithInternalFields; 8526 offset < ViewClass::kSizeWithInternalFields;
8538 offset += kPointerSize) { 8527 offset += kPointerSize) {
8539 Add<HStoreNamedField>(obj, 8528 Add<HStoreNamedField>(obj,
8540 HObjectAccess::ForJSObjectOffset(offset), 8529 HObjectAccess::ForObservableJSObjectPropertyAt(offset),
8541 graph()->GetConstant0(), INITIALIZING_STORE); 8530 graph()->GetConstant0());
8542 } 8531 }
8543 8532
8544 Add<HStoreNamedField>( 8533 Add<HStoreNamedField>(
8545 obj, 8534 obj,
8546 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer, INITIALIZING_STORE); 8535 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer);
8547 Add<HStoreNamedField>( 8536 Add<HStoreNamedField>(
8548 obj, 8537 obj,
8549 HObjectAccess::ForJSArrayBufferViewByteOffset(), 8538 HObjectAccess::ForJSArrayBufferViewByteOffset(),
8550 byte_offset, INITIALIZING_STORE); 8539 byte_offset);
8551 Add<HStoreNamedField>( 8540 Add<HStoreNamedField>(
8552 obj, 8541 obj,
8553 HObjectAccess::ForJSArrayBufferViewByteLength(), 8542 HObjectAccess::ForJSArrayBufferViewByteLength(),
8554 byte_length, INITIALIZING_STORE); 8543 byte_length);
8555 8544
8556 HObjectAccess weak_first_view_access = 8545 HObjectAccess weak_first_view_access =
8557 HObjectAccess::ForJSArrayBufferWeakFirstView(); 8546 HObjectAccess::ForJSArrayBufferWeakFirstView();
8558 Add<HStoreNamedField>(obj, 8547 Add<HStoreNamedField>(obj,
8559 HObjectAccess::ForJSArrayBufferViewWeakNext(), 8548 HObjectAccess::ForJSArrayBufferViewWeakNext(),
8560 Add<HLoadNamedField>(buffer, static_cast<HValue*>(NULL), 8549 Add<HLoadNamedField>(buffer, static_cast<HValue*>(NULL),
8561 weak_first_view_access), 8550 weak_first_view_access));
8562 INITIALIZING_STORE);
8563 Add<HStoreNamedField>( 8551 Add<HStoreNamedField>(
8564 buffer, weak_first_view_access, obj, INITIALIZING_STORE); 8552 buffer, weak_first_view_access, obj);
8565 } 8553 }
8566 8554
8567 8555
8568 void HOptimizedGraphBuilder::VisitDataViewInitialize( 8556 void HOptimizedGraphBuilder::VisitDataViewInitialize(
8569 CallRuntime* expr) { 8557 CallRuntime* expr) {
8570 ZoneList<Expression*>* arguments = expr->arguments(); 8558 ZoneList<Expression*>* arguments = expr->arguments();
8571 8559
8572 NoObservableSideEffectsScope scope(this); 8560 NoObservableSideEffectsScope scope(this);
8573 ASSERT(arguments->length()== 4); 8561 ASSERT(arguments->length()== 4);
8574 CHECK_ALIVE(VisitForValue(arguments->at(0))); 8562 CHECK_ALIVE(VisitForValue(arguments->at(0)));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
8644 8632
8645 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. 8633 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
8646 size_t element_size = 1; // Bogus initialization. 8634 size_t element_size = 1; // Bogus initialization.
8647 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size); 8635 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size);
8648 8636
8649 HInstruction* length = AddUncasted<HDiv>(byte_length, 8637 HInstruction* length = AddUncasted<HDiv>(byte_length,
8650 Add<HConstant>(static_cast<int32_t>(element_size))); 8638 Add<HConstant>(static_cast<int32_t>(element_size)));
8651 8639
8652 Add<HStoreNamedField>(obj, 8640 Add<HStoreNamedField>(obj,
8653 HObjectAccess::ForJSTypedArrayLength(), 8641 HObjectAccess::ForJSTypedArrayLength(),
8654 length, INITIALIZING_STORE); 8642 length);
8655 8643
8656 HValue* elements = 8644 HValue* elements =
8657 Add<HAllocate>( 8645 Add<HAllocate>(
8658 Add<HConstant>(ExternalArray::kAlignedSize), 8646 Add<HConstant>(ExternalArray::kAlignedSize),
8659 HType::JSArray(), 8647 HType::JSArray(),
8660 NOT_TENURED, 8648 NOT_TENURED,
8661 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type)); 8649 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type));
8662 8650
8663 Handle<Map> external_array_map( 8651 Handle<Map> external_array_map(
8664 isolate()->heap()->MapForExternalArrayType(array_type)); 8652 isolate()->heap()->MapForExternalArrayType(array_type));
8665 AddStoreMapConstant(elements, external_array_map); 8653 Add<HStoreNamedField>(elements,
8654 HObjectAccess::ForMap(),
8655 Add<HConstant>(external_array_map));
8666 8656
8667 HValue* backing_store = Add<HLoadNamedField>( 8657 HValue* backing_store = Add<HLoadNamedField>(
8668 buffer, static_cast<HValue*>(NULL), 8658 buffer, static_cast<HValue*>(NULL),
8669 HObjectAccess::ForJSArrayBufferBackingStore()); 8659 HObjectAccess::ForJSArrayBufferBackingStore());
8670 8660
8671 HValue* typed_array_start; 8661 HValue* typed_array_start;
8672 if (is_zero_byte_offset) { 8662 if (is_zero_byte_offset) {
8673 typed_array_start = backing_store; 8663 typed_array_start = backing_store;
8674 } else { 8664 } else {
8675 HInstruction* external_pointer = 8665 HInstruction* external_pointer =
8676 AddUncasted<HAdd>(backing_store, byte_offset); 8666 AddUncasted<HAdd>(backing_store, byte_offset);
8677 // Arguments are checked prior to call to TypedArrayInitialize, 8667 // Arguments are checked prior to call to TypedArrayInitialize,
8678 // including byte_offset. 8668 // including byte_offset.
8679 external_pointer->ClearFlag(HValue::kCanOverflow); 8669 external_pointer->ClearFlag(HValue::kCanOverflow);
8680 typed_array_start = external_pointer; 8670 typed_array_start = external_pointer;
8681 } 8671 }
8682 8672
8673 Add<HStoreNamedField>(elements,
8674 HObjectAccess::ForExternalArrayExternalPointer(),
8675 typed_array_start);
8676 Add<HStoreNamedField>(elements,
8677 HObjectAccess::ForFixedArrayLength(),
8678 length);
8683 Add<HStoreNamedField>( 8679 Add<HStoreNamedField>(
8684 elements, HObjectAccess::ForExternalArrayExternalPointer(), 8680 obj, HObjectAccess::ForElementsPointer(), elements);
8685 typed_array_start, INITIALIZING_STORE);
8686 Add<HStoreNamedField>(
8687 elements, HObjectAccess::ForFixedArrayLength(), length,
8688 INITIALIZING_STORE);
8689 Add<HStoreNamedField>(
8690 obj, HObjectAccess::ForElementsPointer(), elements, INITIALIZING_STORE);
8691 } 8681 }
8692 8682
8693 if (!is_zero_byte_offset) { 8683 if (!is_zero_byte_offset) {
8694 byte_offset_smi.Else(); 8684 byte_offset_smi.Else();
8695 { // byte_offset is not Smi. 8685 { // byte_offset is not Smi.
8696 Push(Add<HPushArgument>(obj)); 8686 Push(Add<HPushArgument>(obj));
8697 VisitArgument(arguments->at(kArrayIdArg)); 8687 VisitArgument(arguments->at(kArrayIdArg));
8698 Push(Add<HPushArgument>(buffer)); 8688 Push(Add<HPushArgument>(buffer));
8699 Push(Add<HPushArgument>(byte_offset)); 8689 Push(Add<HPushArgument>(byte_offset));
8700 Push(Add<HPushArgument>(byte_length)); 8690 Push(Add<HPushArgument>(byte_length));
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
9920 ASSERT(boilerplate_object->properties()->length() == 0); 9910 ASSERT(boilerplate_object->properties()->length() == 0);
9921 9911
9922 Handle<Map> boilerplate_object_map(boilerplate_object->map()); 9912 Handle<Map> boilerplate_object_map(boilerplate_object->map());
9923 AddStoreMapConstant(object, boilerplate_object_map); 9913 AddStoreMapConstant(object, boilerplate_object_map);
9924 9914
9925 Handle<Object> properties_field = 9915 Handle<Object> properties_field =
9926 Handle<Object>(boilerplate_object->properties(), isolate()); 9916 Handle<Object>(boilerplate_object->properties(), isolate());
9927 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); 9917 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array());
9928 HInstruction* properties = Add<HConstant>(properties_field); 9918 HInstruction* properties = Add<HConstant>(properties_field);
9929 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 9919 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
9930 Add<HStoreNamedField>(object, access, properties, INITIALIZING_STORE); 9920 Add<HStoreNamedField>(object, access, properties);
9931 9921
9932 if (boilerplate_object->IsJSArray()) { 9922 if (boilerplate_object->IsJSArray()) {
9933 Handle<JSArray> boilerplate_array = 9923 Handle<JSArray> boilerplate_array =
9934 Handle<JSArray>::cast(boilerplate_object); 9924 Handle<JSArray>::cast(boilerplate_object);
9935 Handle<Object> length_field = 9925 Handle<Object> length_field =
9936 Handle<Object>(boilerplate_array->length(), isolate()); 9926 Handle<Object>(boilerplate_array->length(), isolate());
9937 HInstruction* length = Add<HConstant>(length_field); 9927 HInstruction* length = Add<HConstant>(length_field);
9938 9928
9939 ASSERT(boilerplate_array->length()->IsSmi()); 9929 ASSERT(boilerplate_array->length()->IsSmi());
9940 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( 9930 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(
9941 boilerplate_array->GetElementsKind()), length, INITIALIZING_STORE); 9931 boilerplate_array->GetElementsKind()), length);
9942 } 9932 }
9943 } 9933 }
9944 9934
9945 9935
9946 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( 9936 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader(
9947 Handle<JSObject> boilerplate_object, 9937 Handle<JSObject> boilerplate_object,
9948 HInstruction* object, 9938 HInstruction* object,
9949 HInstruction* object_elements) { 9939 HInstruction* object_elements) {
9950 ASSERT(boilerplate_object->properties()->length() == 0); 9940 ASSERT(boilerplate_object->properties()->length() == 0);
9951 if (object_elements == NULL) { 9941 if (object_elements == NULL) {
9952 Handle<Object> elements_field = 9942 Handle<Object> elements_field =
9953 Handle<Object>(boilerplate_object->elements(), isolate()); 9943 Handle<Object>(boilerplate_object->elements(), isolate());
9954 object_elements = Add<HConstant>(elements_field); 9944 object_elements = Add<HConstant>(elements_field);
9955 } 9945 }
9956 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 9946 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
9957 object_elements, INITIALIZING_STORE); 9947 object_elements);
9958 } 9948 }
9959 9949
9960 9950
9961 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( 9951 void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
9962 Handle<JSObject> boilerplate_object, 9952 Handle<JSObject> boilerplate_object,
9963 HInstruction* object, 9953 HInstruction* object,
9964 AllocationSiteUsageContext* site_context, 9954 AllocationSiteUsageContext* site_context,
9965 PretenureFlag pretenure_flag) { 9955 PretenureFlag pretenure_flag) {
9966 Handle<DescriptorArray> descriptors( 9956 Handle<Map> boilerplate_map(boilerplate_object->map());
9967 boilerplate_object->map()->instance_descriptors()); 9957 Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors());
9968 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); 9958 int limit = boilerplate_map->NumberOfOwnDescriptors();
9969 9959
9970 int copied_fields = 0; 9960 int copied_fields = 0;
9971 for (int i = 0; i < limit; i++) { 9961 for (int i = 0; i < limit; i++) {
9972 PropertyDetails details = descriptors->GetDetails(i); 9962 PropertyDetails details = descriptors->GetDetails(i);
9973 if (details.type() != FIELD) continue; 9963 if (details.type() != FIELD) continue;
9974 copied_fields++; 9964 copied_fields++;
9975 int index = descriptors->GetFieldIndex(i); 9965 int index = descriptors->GetFieldIndex(i);
9976 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); 9966 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index);
9977 Handle<Name> name(descriptors->GetKey(i)); 9967 Handle<Name> name(descriptors->GetKey(i));
9978 Handle<Object> value = 9968 Handle<Object> value =
9979 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), 9969 Handle<Object>(boilerplate_object->InObjectPropertyAt(index),
9980 isolate()); 9970 isolate());
9981 9971
9982 // The access for the store depends on the type of the boilerplate. 9972 // The access for the store depends on the type of the boilerplate.
9983 HObjectAccess access = boilerplate_object->IsJSArray() ? 9973 HObjectAccess access = boilerplate_object->IsJSArray() ?
9984 HObjectAccess::ForJSArrayOffset(property_offset) : 9974 HObjectAccess::ForJSArrayOffset(property_offset) :
9985 HObjectAccess::ForJSObjectOffset(property_offset); 9975 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset);
9986 9976
9987 if (value->IsJSObject()) { 9977 if (value->IsJSObject()) {
9988 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 9978 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
9989 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 9979 Handle<AllocationSite> current_site = site_context->EnterNewScope();
9990 HInstruction* result = 9980 HInstruction* result =
9991 BuildFastLiteral(value_object, site_context); 9981 BuildFastLiteral(value_object, site_context);
9992 site_context->ExitScope(current_site, value_object); 9982 site_context->ExitScope(current_site, value_object);
9993 Add<HStoreNamedField>(object, access, result, INITIALIZING_STORE); 9983 Add<HStoreNamedField>(object, access, result);
9994 } else { 9984 } else {
9995 Representation representation = details.representation(); 9985 Representation representation = details.representation();
9996 HInstruction* value_instruction; 9986 HInstruction* value_instruction;
9997 9987
9998 if (representation.IsDouble()) { 9988 if (representation.IsDouble()) {
9999 // Allocate a HeapNumber box and store the value into it. 9989 // Allocate a HeapNumber box and store the value into it.
10000 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); 9990 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
10001 // This heap number alloc does not have a corresponding 9991 // This heap number alloc does not have a corresponding
10002 // AllocationSite. That is okay because 9992 // AllocationSite. That is okay because
10003 // 1) it's a child object of another object with a valid allocation site 9993 // 1) it's a child object of another object with a valid allocation site
10004 // 2) we can just use the mode of the parent object for pretenuring 9994 // 2) we can just use the mode of the parent object for pretenuring
10005 HInstruction* double_box = 9995 HInstruction* double_box =
10006 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), 9996 Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
10007 pretenure_flag, HEAP_NUMBER_TYPE); 9997 pretenure_flag, HEAP_NUMBER_TYPE);
10008 AddStoreMapConstant(double_box, 9998 AddStoreMapConstant(double_box,
10009 isolate()->factory()->heap_number_map()); 9999 isolate()->factory()->heap_number_map());
10010 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), 10000 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(),
10011 Add<HConstant>(value), INITIALIZING_STORE); 10001 Add<HConstant>(value));
10012 value_instruction = double_box; 10002 value_instruction = double_box;
10013 } else if (representation.IsSmi() && value->IsUninitialized()) { 10003 } else if (representation.IsSmi() && value->IsUninitialized()) {
10014 value_instruction = graph()->GetConstant0(); 10004 value_instruction = graph()->GetConstant0();
10015 } else { 10005 } else {
10016 value_instruction = Add<HConstant>(value); 10006 value_instruction = Add<HConstant>(value);
10017 } 10007 }
10018 10008
10019 Add<HStoreNamedField>(object, access, value_instruction, 10009 Add<HStoreNamedField>(object, access, value_instruction);
10020 INITIALIZING_STORE);
10021 } 10010 }
10022 } 10011 }
10023 10012
10024 int inobject_properties = boilerplate_object->map()->inobject_properties(); 10013 int inobject_properties = boilerplate_object->map()->inobject_properties();
10025 HInstruction* value_instruction = 10014 HInstruction* value_instruction =
10026 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); 10015 Add<HConstant>(isolate()->factory()->one_pointer_filler_map());
10027 for (int i = copied_fields; i < inobject_properties; i++) { 10016 for (int i = copied_fields; i < inobject_properties; i++) {
10028 ASSERT(boilerplate_object->IsJSObject()); 10017 ASSERT(boilerplate_object->IsJSObject());
10029 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); 10018 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i);
10030 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); 10019 HObjectAccess access =
10031 Add<HStoreNamedField>(object, access, value_instruction, 10020 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset);
10032 PREINITIALIZING_STORE); 10021 Add<HStoreNamedField>(object, access, value_instruction);
10033 } 10022 }
10034 } 10023 }
10035 10024
10036 10025
10037 void HOptimizedGraphBuilder::BuildEmitElements( 10026 void HOptimizedGraphBuilder::BuildEmitElements(
10038 Handle<JSObject> boilerplate_object, 10027 Handle<JSObject> boilerplate_object,
10039 Handle<FixedArrayBase> elements, 10028 Handle<FixedArrayBase> elements,
10040 HValue* object_elements, 10029 HValue* object_elements,
10041 AllocationSiteUsageContext* site_context) { 10030 AllocationSiteUsageContext* site_context) {
10042 ElementsKind kind = boilerplate_object->map()->elements_kind(); 10031 ElementsKind kind = boilerplate_object->map()->elements_kind();
(...skipping 19 matching lines...) Expand all
10062 HValue* object_elements) { 10051 HValue* object_elements) {
10063 HInstruction* boilerplate_elements = Add<HConstant>(elements); 10052 HInstruction* boilerplate_elements = Add<HConstant>(elements);
10064 int elements_length = elements->length(); 10053 int elements_length = elements->length();
10065 for (int i = 0; i < elements_length; i++) { 10054 for (int i = 0; i < elements_length; i++) {
10066 HValue* key_constant = Add<HConstant>(i); 10055 HValue* key_constant = Add<HConstant>(i);
10067 HInstruction* value_instruction = 10056 HInstruction* value_instruction =
10068 Add<HLoadKeyed>(boilerplate_elements, key_constant, 10057 Add<HLoadKeyed>(boilerplate_elements, key_constant,
10069 static_cast<HValue*>(NULL), kind, 10058 static_cast<HValue*>(NULL), kind,
10070 ALLOW_RETURN_HOLE); 10059 ALLOW_RETURN_HOLE);
10071 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, 10060 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant,
10072 value_instruction, kind, 10061 value_instruction, kind);
10073 INITIALIZING_STORE);
10074 store->SetFlag(HValue::kAllowUndefinedAsNaN); 10062 store->SetFlag(HValue::kAllowUndefinedAsNaN);
10075 } 10063 }
10076 } 10064 }
10077 10065
10078 10066
10079 void HOptimizedGraphBuilder::BuildEmitFixedArray( 10067 void HOptimizedGraphBuilder::BuildEmitFixedArray(
10080 Handle<FixedArrayBase> elements, 10068 Handle<FixedArrayBase> elements,
10081 ElementsKind kind, 10069 ElementsKind kind,
10082 HValue* object_elements, 10070 HValue* object_elements,
10083 AllocationSiteUsageContext* site_context) { 10071 AllocationSiteUsageContext* site_context) {
10084 HInstruction* boilerplate_elements = Add<HConstant>(elements); 10072 HInstruction* boilerplate_elements = Add<HConstant>(elements);
10085 int elements_length = elements->length(); 10073 int elements_length = elements->length();
10086 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); 10074 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
10087 for (int i = 0; i < elements_length; i++) { 10075 for (int i = 0; i < elements_length; i++) {
10088 Handle<Object> value(fast_elements->get(i), isolate()); 10076 Handle<Object> value(fast_elements->get(i), isolate());
10089 HValue* key_constant = Add<HConstant>(i); 10077 HValue* key_constant = Add<HConstant>(i);
10090 if (value->IsJSObject()) { 10078 if (value->IsJSObject()) {
10091 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 10079 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
10092 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 10080 Handle<AllocationSite> current_site = site_context->EnterNewScope();
10093 HInstruction* result = 10081 HInstruction* result =
10094 BuildFastLiteral(value_object, site_context); 10082 BuildFastLiteral(value_object, site_context);
10095 site_context->ExitScope(current_site, value_object); 10083 site_context->ExitScope(current_site, value_object);
10096 Add<HStoreKeyed>(object_elements, key_constant, result, kind, 10084 Add<HStoreKeyed>(object_elements, key_constant, result, kind);
10097 INITIALIZING_STORE);
10098 } else { 10085 } else {
10099 HInstruction* value_instruction = 10086 HInstruction* value_instruction =
10100 Add<HLoadKeyed>(boilerplate_elements, key_constant, 10087 Add<HLoadKeyed>(boilerplate_elements, key_constant,
10101 static_cast<HValue*>(NULL), kind, 10088 static_cast<HValue*>(NULL), kind,
10102 ALLOW_RETURN_HOLE); 10089 ALLOW_RETURN_HOLE);
10103 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind, 10090 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind);
10104 INITIALIZING_STORE);
10105 } 10091 }
10106 } 10092 }
10107 } 10093 }
10108 10094
10109 10095
10110 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { 10096 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) {
10111 ASSERT(!HasStackOverflow()); 10097 ASSERT(!HasStackOverflow());
10112 ASSERT(current_block() != NULL); 10098 ASSERT(current_block() != NULL);
10113 ASSERT(current_block()->HasPredecessor()); 10099 ASSERT(current_block()->HasPredecessor());
10114 HInstruction* instr = BuildThisFunction(); 10100 HInstruction* instr = BuildThisFunction();
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
10412 HValue* object = Pop(); 10398 HValue* object = Pop();
10413 10399
10414 IfBuilder if_objectisvalue(this); 10400 IfBuilder if_objectisvalue(this);
10415 HValue* objectisvalue = if_objectisvalue.If<HHasInstanceTypeAndBranch>( 10401 HValue* objectisvalue = if_objectisvalue.If<HHasInstanceTypeAndBranch>(
10416 object, JS_VALUE_TYPE); 10402 object, JS_VALUE_TYPE);
10417 if_objectisvalue.Then(); 10403 if_objectisvalue.Then();
10418 { 10404 {
10419 // Return the actual value. 10405 // Return the actual value.
10420 Push(Add<HLoadNamedField>( 10406 Push(Add<HLoadNamedField>(
10421 object, objectisvalue, 10407 object, objectisvalue,
10422 HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset))); 10408 HObjectAccess::ForObservableJSObjectPropertyAt(
10409 JSValue::kValueOffset)));
10423 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10410 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10424 } 10411 }
10425 if_objectisvalue.Else(); 10412 if_objectisvalue.Else();
10426 { 10413 {
10427 // If the object is not a value return the object. 10414 // If the object is not a value return the object.
10428 Push(object); 10415 Push(object);
10429 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10416 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10430 } 10417 }
10431 if_objectisvalue.End(); 10418 if_objectisvalue.End();
10432 return ast_context()->ReturnValue(Pop()); 10419 return ast_context()->ReturnValue(Pop());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
10482 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 10469 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
10483 HValue* value = Pop(); 10470 HValue* value = Pop();
10484 HValue* object = Pop(); 10471 HValue* object = Pop();
10485 10472
10486 // Check if object is a JSValue. 10473 // Check if object is a JSValue.
10487 IfBuilder if_objectisvalue(this); 10474 IfBuilder if_objectisvalue(this);
10488 if_objectisvalue.If<HHasInstanceTypeAndBranch>(object, JS_VALUE_TYPE); 10475 if_objectisvalue.If<HHasInstanceTypeAndBranch>(object, JS_VALUE_TYPE);
10489 if_objectisvalue.Then(); 10476 if_objectisvalue.Then();
10490 { 10477 {
10491 // Create in-object property store to kValueOffset. 10478 // Create in-object property store to kValueOffset.
10492 Add<HStoreNamedField>( 10479 Add<HStoreNamedField>(object,
10493 object, HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), 10480 HObjectAccess::ForObservableJSObjectPropertyAt(JSValue::kValueOffset),
10494 value, INITIALIZING_STORE); 10481 value);
10495 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10482 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10496 } 10483 }
10497 if_objectisvalue.Else(); 10484 if_objectisvalue.Else();
10498 { 10485 {
10499 // Nothing to do in this case. 10486 // Nothing to do in this case.
10500 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10487 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10501 } 10488 }
10502 if_objectisvalue.End(); 10489 if_objectisvalue.End();
10503 return ast_context()->ReturnValue(value); 10490 return ast_context()->ReturnValue(value);
10504 } 10491 }
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
11355 if (ShouldProduceTraceOutput()) { 11342 if (ShouldProduceTraceOutput()) {
11356 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11343 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11357 } 11344 }
11358 11345
11359 #ifdef DEBUG 11346 #ifdef DEBUG
11360 graph_->Verify(false); // No full verify. 11347 graph_->Verify(false); // No full verify.
11361 #endif 11348 #endif
11362 } 11349 }
11363 11350
11364 } } // namespace v8::internal 11351 } } // 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