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

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: Rebasing on r19056. 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 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 capacity_checker.Else(); 1343 capacity_checker.Else();
1344 1344
1345 environment()->Push(elements); 1345 environment()->Push(elements);
1346 capacity_checker.End(); 1346 capacity_checker.End();
1347 1347
1348 if (is_js_array) { 1348 if (is_js_array) {
1349 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); 1349 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1());
1350 new_length->ClearFlag(HValue::kCanOverflow); 1350 new_length->ClearFlag(HValue::kCanOverflow);
1351 1351
1352 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), 1352 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind),
1353 new_length, INITIALIZING_STORE); 1353 new_length);
1354 } 1354 }
1355 1355
1356 if (is_store && kind == FAST_SMI_ELEMENTS) { 1356 if (is_store && kind == FAST_SMI_ELEMENTS) {
1357 HValue* checked_elements = environment()->Top(); 1357 HValue* checked_elements = environment()->Top();
1358 1358
1359 // Write zero to ensure that the new element is initialized with some smi. 1359 // Write zero to ensure that the new element is initialized with some smi.
1360 Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind, 1360 Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind);
1361 INITIALIZING_STORE);
1362 } 1361 }
1363 1362
1364 length_checker.Else(); 1363 length_checker.Else();
1365 Add<HBoundsCheck>(key, length); 1364 Add<HBoundsCheck>(key, length);
1366 1365
1367 environment()->Push(elements); 1366 environment()->Push(elements);
1368 length_checker.End(); 1367 length_checker.End();
1369 1368
1370 return environment()->Pop(); 1369 return environment()->Pop();
1371 } 1370 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 ? Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), 1428 ? Add<HLoadNamedField>(object, static_cast<HValue*>(NULL),
1430 HObjectAccess::ForArrayLength(from_kind)) 1429 HObjectAccess::ForArrayLength(from_kind))
1431 : elements_length; 1430 : elements_length;
1432 1431
1433 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, 1432 BuildGrowElementsCapacity(object, elements, from_kind, to_kind,
1434 array_length, elements_length); 1433 array_length, elements_length);
1435 1434
1436 if_builder.End(); 1435 if_builder.End();
1437 } 1436 }
1438 1437
1439 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map, 1438 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map);
1440 INITIALIZING_STORE);
1441 } 1439 }
1442 1440
1443 1441
1444 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper( 1442 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper(
1445 HValue* elements, 1443 HValue* elements,
1446 HValue* key, 1444 HValue* key,
1447 HValue* hash, 1445 HValue* hash,
1448 HValue* mask, 1446 HValue* mask,
1449 int current_probe) { 1447 int current_probe) {
1450 if (current_probe == kNumberDictionaryProbes) { 1448 if (current_probe == kNumberDictionaryProbes) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 context(), static_cast<HValue*>(NULL), 1598 context(), static_cast<HValue*>(NULL),
1601 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 1599 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
1602 HValue* native_context = Add<HLoadNamedField>( 1600 HValue* native_context = Add<HLoadNamedField>(
1603 global_object, static_cast<HValue*>(NULL), 1601 global_object, static_cast<HValue*>(NULL),
1604 HObjectAccess::ForGlobalObjectNativeContext()); 1602 HObjectAccess::ForGlobalObjectNativeContext());
1605 AddStoreMapNoWriteBarrier(result, Add<HLoadNamedField>( 1603 AddStoreMapNoWriteBarrier(result, Add<HLoadNamedField>(
1606 native_context, static_cast<HValue*>(NULL), 1604 native_context, static_cast<HValue*>(NULL),
1607 HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX))); 1605 HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX)));
1608 Add<HStoreNamedField>( 1606 Add<HStoreNamedField>(
1609 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), 1607 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset),
1610 Add<HConstant>(isolate()->factory()->empty_fixed_array()), 1608 Add<HConstant>(isolate()->factory()->empty_fixed_array()));
1611 INITIALIZING_STORE);
1612 Add<HStoreNamedField>( 1609 Add<HStoreNamedField>(
1613 result, HObjectAccess::ForJSArrayOffset(JSArray::kElementsOffset), 1610 result, HObjectAccess::ForJSArrayOffset(JSArray::kElementsOffset),
1614 elements, INITIALIZING_STORE); 1611 elements);
1615 Add<HStoreNamedField>( 1612 Add<HStoreNamedField>(
1616 result, HObjectAccess::ForJSArrayOffset(JSArray::kLengthOffset), 1613 result, HObjectAccess::ForJSArrayOffset(JSArray::kLengthOffset), length);
1617 length, INITIALIZING_STORE);
1618 1614
1619 // Initialize the additional fields. 1615 // Initialize the additional fields.
1620 Add<HStoreNamedField>( 1616 Add<HStoreNamedField>(
1621 result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kIndexOffset), 1617 result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kIndexOffset),
1622 index, INITIALIZING_STORE); 1618 index);
1623 Add<HStoreNamedField>( 1619 Add<HStoreNamedField>(
1624 result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kInputOffset), 1620 result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kInputOffset),
1625 input, INITIALIZING_STORE); 1621 input);
1626 1622
1627 // Initialize the elements header. 1623 // Initialize the elements header.
1628 AddStoreMapConstantNoWriteBarrier(elements, 1624 AddStoreMapConstantNoWriteBarrier(elements,
1629 isolate()->factory()->fixed_array_map()); 1625 isolate()->factory()->fixed_array_map());
1630 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), 1626 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), length);
1631 length, INITIALIZING_STORE);
1632 1627
1633 // Initialize the elements contents with undefined. 1628 // Initialize the elements contents with undefined.
1634 LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement); 1629 LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement);
1635 index = loop.BeginBody(graph()->GetConstant0(), length, Token::LT); 1630 index = loop.BeginBody(graph()->GetConstant0(), length, Token::LT);
1636 { 1631 {
1637 Add<HStoreKeyed>(elements, index, graph()->GetConstantUndefined(), 1632 Add<HStoreKeyed>(elements, index, graph()->GetConstantUndefined(),
1638 FAST_ELEMENTS, INITIALIZING_STORE); 1633 FAST_ELEMENTS);
1639 } 1634 }
1640 loop.EndBody(); 1635 loop.EndBody();
1641 1636
1642 return result; 1637 return result;
1643 } 1638 }
1644 1639
1645 1640
1646 HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { 1641 HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) {
1647 NoObservableSideEffectsScope scope(this); 1642 NoObservableSideEffectsScope scope(this);
1648 1643
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 if_onebyte.Else(); 1886 if_onebyte.Else();
1892 { 1887 {
1893 // We can safely skip the write barrier for storing the map here. 1888 // We can safely skip the write barrier for storing the map here.
1894 Handle<Map> map = isolate()->factory()->cons_string_map(); 1889 Handle<Map> map = isolate()->factory()->cons_string_map();
1895 AddStoreMapConstantNoWriteBarrier(result, map); 1890 AddStoreMapConstantNoWriteBarrier(result, map);
1896 } 1891 }
1897 if_onebyte.End(); 1892 if_onebyte.End();
1898 1893
1899 // Initialize the cons string fields. 1894 // Initialize the cons string fields.
1900 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), 1895 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(),
1901 Add<HConstant>(String::kEmptyHashField), 1896 Add<HConstant>(String::kEmptyHashField));
1902 INITIALIZING_STORE); 1897 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length);
1903 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length, 1898 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left);
1904 INITIALIZING_STORE); 1899 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right);
1905 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left,
1906 INITIALIZING_STORE);
1907 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right,
1908 INITIALIZING_STORE);
1909 1900
1910 // Count the native string addition. 1901 // Count the native string addition.
1911 AddIncrementCounter(isolate()->counters()->string_add_native()); 1902 AddIncrementCounter(isolate()->counters()->string_add_native());
1912 1903
1913 return result; 1904 return result;
1914 } 1905 }
1915 1906
1916 1907
1917 void HGraphBuilder::BuildCopySeqStringChars(HValue* src, 1908 void HGraphBuilder::BuildCopySeqStringChars(HValue* src,
1918 HValue* src_offset, 1909 HValue* src_offset,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 // Allocate the string object. HAllocate does not care whether we pass 2038 // Allocate the string object. HAllocate does not care whether we pass
2048 // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here. 2039 // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here.
2049 HAllocate* result = BuildAllocate( 2040 HAllocate* result = BuildAllocate(
2050 size, HType::String(), STRING_TYPE, allocation_mode); 2041 size, HType::String(), STRING_TYPE, allocation_mode);
2051 2042
2052 // We can safely skip the write barrier for storing map here. 2043 // We can safely skip the write barrier for storing map here.
2053 AddStoreMapNoWriteBarrier(result, map); 2044 AddStoreMapNoWriteBarrier(result, map);
2054 2045
2055 // Initialize the string fields. 2046 // Initialize the string fields.
2056 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), 2047 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(),
2057 Add<HConstant>(String::kEmptyHashField), 2048 Add<HConstant>(String::kEmptyHashField));
2058 INITIALIZING_STORE); 2049 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length);
2059 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length,
2060 INITIALIZING_STORE);
2061 2050
2062 // Copy characters to the result string. 2051 // Copy characters to the result string.
2063 IfBuilder if_twobyte(this); 2052 IfBuilder if_twobyte(this);
2064 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); 2053 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map);
2065 if_twobyte.Then(); 2054 if_twobyte.Then();
2066 { 2055 {
2067 // Copy characters from the left string. 2056 // Copy characters from the left string.
2068 BuildCopySeqStringChars( 2057 BuildCopySeqStringChars(
2069 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, 2058 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING,
2070 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, 2059 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, 2341 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements,
2353 ElementsKind kind, 2342 ElementsKind kind,
2354 HValue* capacity) { 2343 HValue* capacity) {
2355 Factory* factory = isolate()->factory(); 2344 Factory* factory = isolate()->factory();
2356 Handle<Map> map = IsFastDoubleElementsKind(kind) 2345 Handle<Map> map = IsFastDoubleElementsKind(kind)
2357 ? factory->fixed_double_array_map() 2346 ? factory->fixed_double_array_map()
2358 : factory->fixed_array_map(); 2347 : factory->fixed_array_map();
2359 2348
2360 AddStoreMapConstant(elements, map); 2349 AddStoreMapConstant(elements, map);
2361 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), 2350 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(),
2362 capacity, INITIALIZING_STORE); 2351 capacity);
2363 } 2352 }
2364 2353
2365 2354
2366 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( 2355 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader(
2367 ElementsKind kind, 2356 ElementsKind kind,
2368 HValue* capacity) { 2357 HValue* capacity) {
2369 // The HForceRepresentation is to prevent possible deopt on int-smi 2358 // The HForceRepresentation is to prevent possible deopt on int-smi
2370 // conversion after allocation but before the new object fields are set. 2359 // conversion after allocation but before the new object fields are set.
2371 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); 2360 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi());
2372 HValue* new_elements = BuildAllocateElements(kind, capacity); 2361 HValue* new_elements = BuildAllocateElements(kind, capacity);
2373 BuildInitializeElementsHeader(new_elements, kind, capacity); 2362 BuildInitializeElementsHeader(new_elements, kind, capacity);
2374 return new_elements; 2363 return new_elements;
2375 } 2364 }
2376 2365
2377 2366
2378 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, 2367 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
2379 HValue* array_map, 2368 HValue* array_map,
2380 AllocationSiteMode mode, 2369 AllocationSiteMode mode,
2381 ElementsKind elements_kind, 2370 ElementsKind elements_kind,
2382 HValue* allocation_site_payload, 2371 HValue* allocation_site_payload,
2383 HValue* length_field) { 2372 HValue* length_field) {
2384 2373
2385 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map, 2374 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map);
2386 INITIALIZING_STORE);
2387 2375
2388 HConstant* empty_fixed_array = 2376 HConstant* empty_fixed_array =
2389 Add<HConstant>(isolate()->factory()->empty_fixed_array()); 2377 Add<HConstant>(isolate()->factory()->empty_fixed_array());
2390 2378
2391 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 2379 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
2392 Add<HStoreNamedField>(array, access, empty_fixed_array, INITIALIZING_STORE); 2380 Add<HStoreNamedField>(array, access, empty_fixed_array);
2393 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), 2381 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind),
2394 length_field, INITIALIZING_STORE); 2382 length_field);
2395 2383
2396 if (mode == TRACK_ALLOCATION_SITE) { 2384 if (mode == TRACK_ALLOCATION_SITE) {
2397 BuildCreateAllocationMemento( 2385 BuildCreateAllocationMemento(
2398 array, Add<HConstant>(JSArray::kSize), allocation_site_payload); 2386 array, Add<HConstant>(JSArray::kSize), allocation_site_payload);
2399 } 2387 }
2400 2388
2401 int elements_location = JSArray::kSize; 2389 int elements_location = JSArray::kSize;
2402 if (mode == TRACK_ALLOCATION_SITE) { 2390 if (mode == TRACK_ALLOCATION_SITE) {
2403 elements_location += AllocationMemento::kSize; 2391 elements_location += AllocationMemento::kSize;
2404 } 2392 }
2405 2393
2406 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>( 2394 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>(
2407 array, Add<HConstant>(elements_location)); 2395 array, Add<HConstant>(elements_location));
2408 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements, 2396 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements);
2409 INITIALIZING_STORE);
2410 return elements; 2397 return elements;
2411 } 2398 }
2412 2399
2413 2400
2414 HInstruction* HGraphBuilder::AddElementAccess( 2401 HInstruction* HGraphBuilder::AddElementAccess(
2415 HValue* elements, 2402 HValue* elements,
2416 HValue* checked_key, 2403 HValue* checked_key,
2417 HValue* val, 2404 HValue* val,
2418 HValue* dependency, 2405 HValue* dependency,
2419 ElementsKind elements_kind, 2406 ElementsKind elements_kind,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 BuildNewSpaceArrayCheck(new_capacity, new_kind); 2478 BuildNewSpaceArrayCheck(new_capacity, new_kind);
2492 2479
2493 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( 2480 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader(
2494 new_kind, new_capacity); 2481 new_kind, new_capacity);
2495 2482
2496 BuildCopyElements(elements, kind, 2483 BuildCopyElements(elements, kind,
2497 new_elements, new_kind, 2484 new_elements, new_kind,
2498 length, new_capacity); 2485 length, new_capacity);
2499 2486
2500 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 2487 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
2501 new_elements, INITIALIZING_STORE); 2488 new_elements);
2502 2489
2503 return new_elements; 2490 return new_elements;
2504 } 2491 }
2505 2492
2506 2493
2507 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, 2494 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements,
2508 ElementsKind elements_kind, 2495 ElementsKind elements_kind,
2509 HValue* from, 2496 HValue* from,
2510 HValue* to) { 2497 HValue* to) {
2511 // Fast elements kinds need to be initialized in case statements below cause 2498 // Fast elements kinds need to be initialized in case statements below cause
(...skipping 20 matching lines...) Expand all
2532 2519
2533 // Since we're about to store a hole value, the store instruction below must 2520 // Since we're about to store a hole value, the store instruction below must
2534 // assume an elements kind that supports heap object values. 2521 // assume an elements kind that supports heap object values.
2535 if (IsFastSmiOrObjectElementsKind(elements_kind)) { 2522 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
2536 elements_kind = FAST_HOLEY_ELEMENTS; 2523 elements_kind = FAST_HOLEY_ELEMENTS;
2537 } 2524 }
2538 2525
2539 if (initial_capacity >= 0) { 2526 if (initial_capacity >= 0) {
2540 for (int i = 0; i < initial_capacity; i++) { 2527 for (int i = 0; i < initial_capacity; i++) {
2541 HInstruction* key = Add<HConstant>(i); 2528 HInstruction* key = Add<HConstant>(i);
2542 Add<HStoreKeyed>(elements, key, hole, elements_kind, 2529 Add<HStoreKeyed>(elements, key, hole, elements_kind);
2543 PREINITIALIZING_STORE);
2544 } 2530 }
2545 } else { 2531 } else {
2546 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); 2532 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement);
2547 2533
2548 HValue* key = builder.BeginBody(from, to, Token::LT); 2534 HValue* key = builder.BeginBody(from, to, Token::LT);
2549 2535
2550 Add<HStoreKeyed>(elements, key, hole, elements_kind, PREINITIALIZING_STORE); 2536 Add<HStoreKeyed>(elements, key, hole, elements_kind);
2551 2537
2552 builder.EndBody(); 2538 builder.EndBody();
2553 } 2539 }
2554 } 2540 }
2555 2541
2556 2542
2557 void HGraphBuilder::BuildCopyElements(HValue* from_elements, 2543 void HGraphBuilder::BuildCopyElements(HValue* from_elements,
2558 ElementsKind from_elements_kind, 2544 ElementsKind from_elements_kind,
2559 HValue* to_elements, 2545 HValue* to_elements,
2560 ElementsKind to_elements_kind, 2546 ElementsKind to_elements_kind,
(...skipping 25 matching lines...) Expand all
2586 ? FAST_HOLEY_ELEMENTS : to_elements_kind; 2572 ? FAST_HOLEY_ELEMENTS : to_elements_kind;
2587 2573
2588 if (IsHoleyElementsKind(from_elements_kind) && 2574 if (IsHoleyElementsKind(from_elements_kind) &&
2589 from_elements_kind != to_elements_kind) { 2575 from_elements_kind != to_elements_kind) {
2590 IfBuilder if_hole(this); 2576 IfBuilder if_hole(this);
2591 if_hole.If<HCompareHoleAndBranch>(element); 2577 if_hole.If<HCompareHoleAndBranch>(element);
2592 if_hole.Then(); 2578 if_hole.Then();
2593 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind) 2579 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind)
2594 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double()) 2580 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double())
2595 : graph()->GetConstantHole(); 2581 : graph()->GetConstantHole();
2596 Add<HStoreKeyed>(to_elements, key, hole_constant, kind, 2582 Add<HStoreKeyed>(to_elements, key, hole_constant, kind);
2597 PREINITIALIZING_STORE);
2598 if_hole.Else(); 2583 if_hole.Else();
2599 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind, 2584 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind);
2600 INITIALIZING_STORE);
2601 store->SetFlag(HValue::kAllowUndefinedAsNaN); 2585 store->SetFlag(HValue::kAllowUndefinedAsNaN);
2602 if_hole.End(); 2586 if_hole.End();
2603 } else { 2587 } else {
2604 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind, 2588 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind);
2605 INITIALIZING_STORE);
2606 store->SetFlag(HValue::kAllowUndefinedAsNaN); 2589 store->SetFlag(HValue::kAllowUndefinedAsNaN);
2607 } 2590 }
2608 2591
2609 builder.EndBody(); 2592 builder.EndBody();
2610 2593
2611 if (!pre_fill_with_holes && length != capacity) { 2594 if (!pre_fill_with_holes && length != capacity) {
2612 // Fill unused capacity with the hole. 2595 // Fill unused capacity with the hole.
2613 BuildFillElementsWithHole(to_elements, to_elements_kind, 2596 BuildFillElementsWithHole(to_elements, to_elements_kind,
2614 key, capacity); 2597 key, capacity);
2615 } 2598 }
(...skipping 18 matching lines...) Expand all
2634 HType::JSObject(), 2617 HType::JSObject(),
2635 NOT_TENURED, 2618 NOT_TENURED,
2636 JS_OBJECT_TYPE); 2619 JS_OBJECT_TYPE);
2637 2620
2638 // Copy the JS array part. 2621 // Copy the JS array part.
2639 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { 2622 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
2640 if ((i != JSArray::kElementsOffset) || (length == 0)) { 2623 if ((i != JSArray::kElementsOffset) || (length == 0)) {
2641 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); 2624 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i);
2642 Add<HStoreNamedField>( 2625 Add<HStoreNamedField>(
2643 object, access, Add<HLoadNamedField>( 2626 object, access, Add<HLoadNamedField>(
2644 boilerplate, static_cast<HValue*>(NULL), access), 2627 boilerplate, static_cast<HValue*>(NULL), access));
2645 INITIALIZING_STORE);
2646 } 2628 }
2647 } 2629 }
2648 2630
2649 // Create an allocation site info if requested. 2631 // Create an allocation site info if requested.
2650 if (mode == TRACK_ALLOCATION_SITE) { 2632 if (mode == TRACK_ALLOCATION_SITE) {
2651 BuildCreateAllocationMemento( 2633 BuildCreateAllocationMemento(
2652 object, Add<HConstant>(JSArray::kSize), allocation_site); 2634 object, Add<HConstant>(JSArray::kSize), allocation_site);
2653 } 2635 }
2654 2636
2655 if (length > 0) { 2637 if (length > 0) {
2656 HValue* boilerplate_elements = AddLoadElements(boilerplate); 2638 HValue* boilerplate_elements = AddLoadElements(boilerplate);
2657 HValue* object_elements; 2639 HValue* object_elements;
2658 if (IsFastDoubleElementsKind(kind)) { 2640 if (IsFastDoubleElementsKind(kind)) {
2659 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); 2641 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length));
2660 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), 2642 object_elements = Add<HAllocate>(elems_size, HType::JSArray(),
2661 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); 2643 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE);
2662 } else { 2644 } else {
2663 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); 2645 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length));
2664 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), 2646 object_elements = Add<HAllocate>(elems_size, HType::JSArray(),
2665 NOT_TENURED, FIXED_ARRAY_TYPE); 2647 NOT_TENURED, FIXED_ARRAY_TYPE);
2666 } 2648 }
2667 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 2649 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
2668 object_elements, INITIALIZING_STORE); 2650 object_elements);
2669 2651
2670 // Copy the elements array header. 2652 // Copy the elements array header.
2671 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { 2653 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) {
2672 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); 2654 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i);
2673 Add<HStoreNamedField>( 2655 Add<HStoreNamedField>(
2674 object_elements, access, Add<HLoadNamedField>( 2656 object_elements, access, Add<HLoadNamedField>(
2675 boilerplate_elements, static_cast<HValue*>(NULL), access), 2657 boilerplate_elements, static_cast<HValue*>(NULL), access));
2676 INITIALIZING_STORE);
2677 } 2658 }
2678 2659
2679 // Copy the elements array contents. 2660 // Copy the elements array contents.
2680 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold 2661 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold
2681 // copying loops with constant length up to a given boundary and use this 2662 // copying loops with constant length up to a given boundary and use this
2682 // helper here instead. 2663 // helper here instead.
2683 for (int i = 0; i < length; i++) { 2664 for (int i = 0; i < length; i++) {
2684 HValue* key_constant = Add<HConstant>(i); 2665 HValue* key_constant = Add<HConstant>(i);
2685 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, 2666 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant,
2686 static_cast<HValue*>(NULL), kind); 2667 static_cast<HValue*>(NULL), kind);
2687 Add<HStoreKeyed>(object_elements, key_constant, value, kind, 2668 Add<HStoreKeyed>(object_elements, key_constant, value, kind);
2688 INITIALIZING_STORE);
2689 } 2669 }
2690 } 2670 }
2691 2671
2692 return object; 2672 return object;
2693 } 2673 }
2694 2674
2695 2675
2696 void HGraphBuilder::BuildCompareNil( 2676 void HGraphBuilder::BuildCompareNil(
2697 HValue* value, 2677 HValue* value,
2698 Type* type, 2678 Type* type,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 void HGraphBuilder::BuildCreateAllocationMemento( 2728 void HGraphBuilder::BuildCreateAllocationMemento(
2749 HValue* previous_object, 2729 HValue* previous_object,
2750 HValue* previous_object_size, 2730 HValue* previous_object_size,
2751 HValue* allocation_site) { 2731 HValue* allocation_site) {
2752 ASSERT(allocation_site != NULL); 2732 ASSERT(allocation_site != NULL);
2753 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( 2733 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>(
2754 previous_object, previous_object_size); 2734 previous_object, previous_object_size);
2755 AddStoreMapConstant( 2735 AddStoreMapConstant(
2756 allocation_memento, isolate()->factory()->allocation_memento_map()); 2736 allocation_memento, isolate()->factory()->allocation_memento_map());
2757 Add<HStoreNamedField>( 2737 Add<HStoreNamedField>(
2758 allocation_memento, HObjectAccess::ForAllocationMementoSite(), 2738 allocation_memento,
2759 allocation_site, INITIALIZING_STORE); 2739 HObjectAccess::ForAllocationMementoSite(),
2740 allocation_site);
2760 if (FLAG_allocation_site_pretenuring) { 2741 if (FLAG_allocation_site_pretenuring) {
2761 HValue* memento_create_count = Add<HLoadNamedField>( 2742 HValue* memento_create_count = Add<HLoadNamedField>(
2762 allocation_site, static_cast<HValue*>(NULL), 2743 allocation_site, static_cast<HValue*>(NULL),
2763 HObjectAccess::ForAllocationSiteOffset( 2744 HObjectAccess::ForAllocationSiteOffset(
2764 AllocationSite::kPretenureCreateCountOffset)); 2745 AllocationSite::kPretenureCreateCountOffset));
2765 memento_create_count = AddUncasted<HAdd>( 2746 memento_create_count = AddUncasted<HAdd>(
2766 memento_create_count, graph()->GetConstant1()); 2747 memento_create_count, graph()->GetConstant1());
2767 // This smi value is reset to zero after every gc, overflow isn't a problem 2748 // This smi value is reset to zero after every gc, overflow isn't a problem
2768 // since the counter is bounded by the new space size. 2749 // since the counter is bounded by the new space size.
2769 memento_create_count->ClearFlag(HValue::kCanOverflow); 2750 memento_create_count->ClearFlag(HValue::kCanOverflow);
2770 HStoreNamedField* store = Add<HStoreNamedField>( 2751 HStoreNamedField* store = Add<HStoreNamedField>(
2771 allocation_site, HObjectAccess::ForAllocationSiteOffset( 2752 allocation_site, HObjectAccess::ForAllocationSiteOffset(
2772 AllocationSite::kPretenureCreateCountOffset), memento_create_count, 2753 AllocationSite::kPretenureCreateCountOffset), memento_create_count);
2773 INITIALIZING_STORE);
2774 // No write barrier needed to store a smi. 2754 // No write barrier needed to store a smi.
2775 store->SkipWriteBarrier(); 2755 store->SkipWriteBarrier();
2776 } 2756 }
2777 } 2757 }
2778 2758
2779 2759
2780 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { 2760 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) {
2781 // Get the global context, then the native context 2761 // Get the global context, then the native context
2782 HInstruction* context = 2762 HInstruction* context =
2783 Add<HLoadNamedField>(closure, static_cast<HValue*>(NULL), 2763 Add<HLoadNamedField>(closure, static_cast<HValue*>(NULL),
2784 HObjectAccess::ForFunctionContextPointer()); 2764 HObjectAccess::ForFunctionContextPointer());
2785 HInstruction* global_object = Add<HLoadNamedField>( 2765 HInstruction* global_object = Add<HLoadNamedField>(
2786 context, static_cast<HValue*>(NULL), 2766 context, static_cast<HValue*>(NULL),
2787 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 2767 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2788 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 2768 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(
2789 GlobalObject::kNativeContextOffset); 2769 GlobalObject::kNativeContextOffset);
2790 return Add<HLoadNamedField>( 2770 return Add<HLoadNamedField>(
2791 global_object, static_cast<HValue*>(NULL), access); 2771 global_object, static_cast<HValue*>(NULL), access);
2792 } 2772 }
2793 2773
2794 2774
2795 HInstruction* HGraphBuilder::BuildGetNativeContext() { 2775 HInstruction* HGraphBuilder::BuildGetNativeContext() {
2796 // Get the global context, then the native context 2776 // Get the global context, then the native context
2797 HValue* global_object = Add<HLoadNamedField>( 2777 HValue* global_object = Add<HLoadNamedField>(
2798 context(), static_cast<HValue*>(NULL), 2778 context(), static_cast<HValue*>(NULL),
2799 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 2779 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2800 return Add<HLoadNamedField>( 2780 return Add<HLoadNamedField>(
2801 global_object, static_cast<HValue*>(NULL), 2781 global_object, static_cast<HValue*>(NULL),
2802 HObjectAccess::ForJSObjectOffset(GlobalObject::kNativeContextOffset)); 2782 HObjectAccess::ForObservableJSObjectOffset(
2783 GlobalObject::kNativeContextOffset));
2803 } 2784 }
2804 2785
2805 2786
2806 HInstruction* HGraphBuilder::BuildGetArrayFunction() { 2787 HInstruction* HGraphBuilder::BuildGetArrayFunction() {
2807 HInstruction* native_context = BuildGetNativeContext(); 2788 HInstruction* native_context = BuildGetNativeContext();
2808 HInstruction* index = 2789 HInstruction* index =
2809 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX)); 2790 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX));
2810 return Add<HLoadKeyed>( 2791 return Add<HLoadKeyed>(
2811 native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS); 2792 native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS);
2812 } 2793 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 graph()->GetConstant0(), capacity); 2964 graph()->GetConstant0(), capacity);
2984 } 2965 }
2985 2966
2986 return new_object; 2967 return new_object;
2987 } 2968 }
2988 2969
2989 2970
2990 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, 2971 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object,
2991 Handle<Map> map) { 2972 Handle<Map> map) {
2992 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), 2973 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
2993 Add<HConstant>(map), INITIALIZING_STORE); 2974 Add<HConstant>(map));
2994 } 2975 }
2995 2976
2996 2977
2997 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { 2978 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) {
2998 HValue* global_object = Add<HLoadNamedField>( 2979 HValue* global_object = Add<HLoadNamedField>(
2999 context(), static_cast<HValue*>(NULL), 2980 context(), static_cast<HValue*>(NULL),
3000 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 2981 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
3001 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 2982 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(
3002 GlobalObject::kBuiltinsOffset); 2983 GlobalObject::kBuiltinsOffset);
3003 HValue* builtins = Add<HLoadNamedField>( 2984 HValue* builtins = Add<HLoadNamedField>(
3004 global_object, static_cast<HValue*>(NULL), access); 2985 global_object, static_cast<HValue*>(NULL), access);
3005 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset( 2986 HObjectAccess function_access = HObjectAccess::ForObservableJSObjectOffset(
3006 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); 2987 JSBuiltinsObject::OffsetOfFunctionWithId(builtin));
3007 return Add<HLoadNamedField>( 2988 return Add<HLoadNamedField>(
3008 builtins, static_cast<HValue*>(NULL), function_access); 2989 builtins, static_cast<HValue*>(NULL), function_access);
3009 } 2990 }
3010 2991
3011 2992
3012 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) 2993 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
3013 : HGraphBuilder(info), 2994 : HGraphBuilder(info),
3014 function_state_(NULL), 2995 function_state_(NULL),
3015 initial_function_state_(this, info, NORMAL_RETURN), 2996 initial_function_state_(this, info, NORMAL_RETURN),
3016 ast_context_(NULL), 2997 ast_context_(NULL),
(...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 HValue* key = Add<HConstant>(i); 5296 HValue* key = Add<HConstant>(i);
5316 5297
5317 switch (boilerplate_elements_kind) { 5298 switch (boilerplate_elements_kind) {
5318 case FAST_SMI_ELEMENTS: 5299 case FAST_SMI_ELEMENTS:
5319 case FAST_HOLEY_SMI_ELEMENTS: 5300 case FAST_HOLEY_SMI_ELEMENTS:
5320 case FAST_ELEMENTS: 5301 case FAST_ELEMENTS:
5321 case FAST_HOLEY_ELEMENTS: 5302 case FAST_HOLEY_ELEMENTS:
5322 case FAST_DOUBLE_ELEMENTS: 5303 case FAST_DOUBLE_ELEMENTS:
5323 case FAST_HOLEY_DOUBLE_ELEMENTS: { 5304 case FAST_HOLEY_DOUBLE_ELEMENTS: {
5324 HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, 5305 HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value,
5325 boilerplate_elements_kind, 5306 boilerplate_elements_kind);
5326 INITIALIZING_STORE);
5327 instr->SetUninitialized(uninitialized); 5307 instr->SetUninitialized(uninitialized);
5328 break; 5308 break;
5329 } 5309 }
5330 default: 5310 default:
5331 UNREACHABLE(); 5311 UNREACHABLE();
5332 break; 5312 break;
5333 } 5313 }
5334 5314
5335 Add<HSimulate>(expr->GetIdForElement(i)); 5315 Add<HSimulate>(expr->GetIdForElement(i));
5336 } 5316 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5397 5377
5398 PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ? 5378 PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ?
5399 isolate()->heap()->GetPretenureMode() : NOT_TENURED; 5379 isolate()->heap()->GetPretenureMode() : NOT_TENURED;
5400 5380
5401 HInstruction* heap_number = Add<HAllocate>(heap_number_size, 5381 HInstruction* heap_number = Add<HAllocate>(heap_number_size,
5402 HType::HeapNumber(), 5382 HType::HeapNumber(),
5403 pretenure_flag, 5383 pretenure_flag,
5404 HEAP_NUMBER_TYPE); 5384 HEAP_NUMBER_TYPE);
5405 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map()); 5385 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map());
5406 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), 5386 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(),
5407 value, INITIALIZING_STORE); 5387 value);
5408 instr = New<HStoreNamedField>(checked_object->ActualValue(), 5388 instr = New<HStoreNamedField>(checked_object->ActualValue(),
5409 heap_number_access, 5389 heap_number_access,
5410 heap_number, INITIALIZING_STORE); 5390 heap_number);
5411 } else { 5391 } else {
5412 // Already holds a HeapNumber; load the box and write its value field. 5392 // Already holds a HeapNumber; load the box and write its value field.
5413 HInstruction* heap_number = Add<HLoadNamedField>( 5393 HInstruction* heap_number = Add<HLoadNamedField>(
5414 checked_object, static_cast<HValue*>(NULL), heap_number_access); 5394 checked_object, static_cast<HValue*>(NULL), heap_number_access);
5415 heap_number->set_type(HType::HeapNumber()); 5395 heap_number->set_type(HType::HeapNumber());
5416 instr = New<HStoreNamedField>(heap_number, 5396 instr = New<HStoreNamedField>(heap_number,
5417 HObjectAccess::ForHeapNumberValue(), 5397 HObjectAccess::ForHeapNumberValue(),
5418 value, STORE_TO_INITIALIZED_ENTRY); 5398 value, STORE_TO_INITIALIZED_ENTRY);
5419 } 5399 }
5420 } else { 5400 } else {
(...skipping 2910 matching lines...) Expand 10 before | Expand all | Expand 10 after
8331 // TODO(mvstanton): If all the arguments are constants in smi range, then 8311 // TODO(mvstanton): If all the arguments are constants in smi range, then
8332 // we could set fill_with_hole to false and save a few instructions. 8312 // we could set fill_with_hole to false and save a few instructions.
8333 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind) 8313 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind)
8334 ? JSArrayBuilder::FILL_WITH_HOLE 8314 ? JSArrayBuilder::FILL_WITH_HOLE
8335 : JSArrayBuilder::DONT_FILL_WITH_HOLE; 8315 : JSArrayBuilder::DONT_FILL_WITH_HOLE;
8336 new_object = array_builder.AllocateArray(length, length, fill_mode); 8316 new_object = array_builder.AllocateArray(length, length, fill_mode);
8337 HValue* elements = array_builder.GetElementsLocation(); 8317 HValue* elements = array_builder.GetElementsLocation();
8338 for (int i = 0; i < argument_count; i++) { 8318 for (int i = 0; i < argument_count; i++) {
8339 HValue* value = environment()->ExpressionStackAt(argument_count - i - 1); 8319 HValue* value = environment()->ExpressionStackAt(argument_count - i - 1);
8340 HValue* constant_i = Add<HConstant>(i); 8320 HValue* constant_i = Add<HConstant>(i);
8341 Add<HStoreKeyed>(elements, constant_i, value, kind, INITIALIZING_STORE); 8321 Add<HStoreKeyed>(elements, constant_i, value, kind);
8342 } 8322 }
8343 } 8323 }
8344 8324
8345 Drop(argument_count + 1); // drop constructor and args. 8325 Drop(argument_count + 1); // drop constructor and args.
8346 ast_context()->ReturnValue(new_object); 8326 ast_context()->ReturnValue(new_object);
8347 } 8327 }
8348 8328
8349 8329
8350 // Checks whether allocation using the given constructor can be inlined. 8330 // Checks whether allocation using the given constructor can be inlined.
8351 static bool IsAllocationInlineable(Handle<JSFunction> constructor) { 8331 static bool IsAllocationInlineable(Handle<JSFunction> constructor) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
8440 isolate()->heap()->GetPretenureMode() : NOT_TENURED; 8420 isolate()->heap()->GetPretenureMode() : NOT_TENURED;
8441 HAllocate* receiver = 8421 HAllocate* receiver =
8442 Add<HAllocate>(size_in_bytes, HType::JSObject(), pretenure_flag, 8422 Add<HAllocate>(size_in_bytes, HType::JSObject(), pretenure_flag,
8443 JS_OBJECT_TYPE); 8423 JS_OBJECT_TYPE);
8444 receiver->set_known_initial_map(initial_map); 8424 receiver->set_known_initial_map(initial_map);
8445 8425
8446 // Load the initial map from the constructor. 8426 // Load the initial map from the constructor.
8447 HValue* constructor_value = Add<HConstant>(constructor); 8427 HValue* constructor_value = Add<HConstant>(constructor);
8448 HValue* initial_map_value = 8428 HValue* initial_map_value =
8449 Add<HLoadNamedField>(constructor_value, static_cast<HValue*>(NULL), 8429 Add<HLoadNamedField>(constructor_value, static_cast<HValue*>(NULL),
8450 HObjectAccess::ForJSObjectOffset( 8430 HObjectAccess::ForMapAndOffset(
8431 handle(constructor->map()),
8451 JSFunction::kPrototypeOrInitialMapOffset)); 8432 JSFunction::kPrototypeOrInitialMapOffset));
8452 8433
8453 // Initialize map and fields of the newly allocated object. 8434 // Initialize map and fields of the newly allocated object.
8454 { NoObservableSideEffectsScope no_effects(this); 8435 { NoObservableSideEffectsScope no_effects(this);
8455 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); 8436 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
8456 Add<HStoreNamedField>(receiver, 8437 Add<HStoreNamedField>(receiver,
8457 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), 8438 HObjectAccess::ForMapAndOffset(initial_map, JSObject::kMapOffset),
8458 initial_map_value, INITIALIZING_STORE); 8439 initial_map_value);
8459 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); 8440 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array());
8460 Add<HStoreNamedField>(receiver, 8441 Add<HStoreNamedField>(receiver,
8461 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), 8442 HObjectAccess::ForMapAndOffset(initial_map,
8462 empty_fixed_array, INITIALIZING_STORE); 8443 JSObject::kPropertiesOffset),
8444 empty_fixed_array);
8463 Add<HStoreNamedField>(receiver, 8445 Add<HStoreNamedField>(receiver,
8464 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), 8446 HObjectAccess::ForMapAndOffset(initial_map,
8465 empty_fixed_array, INITIALIZING_STORE); 8447 JSObject::kElementsOffset),
8448 empty_fixed_array);
8466 if (initial_map->inobject_properties() != 0) { 8449 if (initial_map->inobject_properties() != 0) {
8467 HConstant* undefined = graph()->GetConstantUndefined(); 8450 HConstant* undefined = graph()->GetConstantUndefined();
8468 for (int i = 0; i < initial_map->inobject_properties(); i++) { 8451 for (int i = 0; i < initial_map->inobject_properties(); i++) {
8469 int property_offset = JSObject::kHeaderSize + i * kPointerSize; 8452 int property_offset = initial_map->GetInObjectPropertyOffset(i);
8470 Add<HStoreNamedField>(receiver, 8453 Add<HStoreNamedField>(receiver,
8471 HObjectAccess::ForJSObjectOffset(property_offset), 8454 HObjectAccess::ForMapAndOffset(initial_map, property_offset),
8472 undefined, PREINITIALIZING_STORE); 8455 undefined);
8473 } 8456 }
8474 } 8457 }
8475 } 8458 }
8476 8459
8477 // Replace the constructor function with a newly allocated receiver using 8460 // Replace the constructor function with a newly allocated receiver using
8478 // the index of the receiver from the top of the expression stack. 8461 // the index of the receiver from the top of the expression stack.
8479 const int receiver_index = argument_count - 1; 8462 const int receiver_index = argument_count - 1;
8480 ASSERT(environment()->ExpressionStackAt(receiver_index) == function); 8463 ASSERT(environment()->ExpressionStackAt(receiver_index) == function);
8481 environment()->SetExpressionStackAt(receiver_index, receiver); 8464 environment()->SetExpressionStackAt(receiver_index, receiver);
8482 8465
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
8546 void HGraphBuilder::BuildArrayBufferViewInitialization( 8529 void HGraphBuilder::BuildArrayBufferViewInitialization(
8547 HValue* obj, 8530 HValue* obj,
8548 HValue* buffer, 8531 HValue* buffer,
8549 HValue* byte_offset, 8532 HValue* byte_offset,
8550 HValue* byte_length) { 8533 HValue* byte_length) {
8551 8534
8552 for (int offset = ViewClass::kSize; 8535 for (int offset = ViewClass::kSize;
8553 offset < ViewClass::kSizeWithInternalFields; 8536 offset < ViewClass::kSizeWithInternalFields;
8554 offset += kPointerSize) { 8537 offset += kPointerSize) {
8555 Add<HStoreNamedField>(obj, 8538 Add<HStoreNamedField>(obj,
8556 HObjectAccess::ForJSObjectOffset(offset), 8539 HObjectAccess::ForObservableJSObjectOffset(offset),
8557 graph()->GetConstant0(), INITIALIZING_STORE); 8540 graph()->GetConstant0());
8558 } 8541 }
8559 8542
8560 Add<HStoreNamedField>( 8543 Add<HStoreNamedField>(
8561 obj, 8544 obj,
8562 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer, INITIALIZING_STORE); 8545 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer);
8563 Add<HStoreNamedField>( 8546 Add<HStoreNamedField>(
8564 obj, 8547 obj,
8565 HObjectAccess::ForJSArrayBufferViewByteOffset(), 8548 HObjectAccess::ForJSArrayBufferViewByteOffset(),
8566 byte_offset, INITIALIZING_STORE); 8549 byte_offset);
8567 Add<HStoreNamedField>( 8550 Add<HStoreNamedField>(
8568 obj, 8551 obj,
8569 HObjectAccess::ForJSArrayBufferViewByteLength(), 8552 HObjectAccess::ForJSArrayBufferViewByteLength(),
8570 byte_length, INITIALIZING_STORE); 8553 byte_length);
8571 8554
8572 HObjectAccess weak_first_view_access = 8555 HObjectAccess weak_first_view_access =
8573 HObjectAccess::ForJSArrayBufferWeakFirstView(); 8556 HObjectAccess::ForJSArrayBufferWeakFirstView();
8574 Add<HStoreNamedField>(obj, 8557 Add<HStoreNamedField>(obj,
8575 HObjectAccess::ForJSArrayBufferViewWeakNext(), 8558 HObjectAccess::ForJSArrayBufferViewWeakNext(),
8576 Add<HLoadNamedField>(buffer, static_cast<HValue*>(NULL), 8559 Add<HLoadNamedField>(buffer, static_cast<HValue*>(NULL),
8577 weak_first_view_access), 8560 weak_first_view_access));
8578 INITIALIZING_STORE);
8579 Add<HStoreNamedField>( 8561 Add<HStoreNamedField>(
8580 buffer, weak_first_view_access, obj, INITIALIZING_STORE); 8562 buffer, weak_first_view_access, obj);
8581 } 8563 }
8582 8564
8583 8565
8584 void HOptimizedGraphBuilder::VisitDataViewInitialize( 8566 void HOptimizedGraphBuilder::VisitDataViewInitialize(
8585 CallRuntime* expr) { 8567 CallRuntime* expr) {
8586 ZoneList<Expression*>* arguments = expr->arguments(); 8568 ZoneList<Expression*>* arguments = expr->arguments();
8587 8569
8588 NoObservableSideEffectsScope scope(this); 8570 NoObservableSideEffectsScope scope(this);
8589 ASSERT(arguments->length()== 4); 8571 ASSERT(arguments->length()== 4);
8590 CHECK_ALIVE(VisitForValue(arguments->at(0))); 8572 CHECK_ALIVE(VisitForValue(arguments->at(0)));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
8660 8642
8661 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. 8643 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
8662 size_t element_size = 1; // Bogus initialization. 8644 size_t element_size = 1; // Bogus initialization.
8663 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size); 8645 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size);
8664 8646
8665 HInstruction* length = AddUncasted<HDiv>(byte_length, 8647 HInstruction* length = AddUncasted<HDiv>(byte_length,
8666 Add<HConstant>(static_cast<int32_t>(element_size))); 8648 Add<HConstant>(static_cast<int32_t>(element_size)));
8667 8649
8668 Add<HStoreNamedField>(obj, 8650 Add<HStoreNamedField>(obj,
8669 HObjectAccess::ForJSTypedArrayLength(), 8651 HObjectAccess::ForJSTypedArrayLength(),
8670 length, INITIALIZING_STORE); 8652 length);
8671 8653
8672 HValue* elements = 8654 HValue* elements =
8673 Add<HAllocate>( 8655 Add<HAllocate>(
8674 Add<HConstant>(ExternalArray::kAlignedSize), 8656 Add<HConstant>(ExternalArray::kAlignedSize),
8675 HType::JSArray(), 8657 HType::JSArray(),
8676 NOT_TENURED, 8658 NOT_TENURED,
8677 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type)); 8659 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type));
8678 8660
8679 Handle<Map> external_array_map( 8661 Handle<Map> external_array_map(
8680 isolate()->heap()->MapForExternalArrayType(array_type)); 8662 isolate()->heap()->MapForExternalArrayType(array_type));
8681 AddStoreMapConstant(elements, external_array_map); 8663 Add<HStoreNamedField>(elements,
8664 HObjectAccess::ForMap(),
8665 Add<HConstant>(external_array_map));
8682 8666
8683 HValue* backing_store = Add<HLoadNamedField>( 8667 HValue* backing_store = Add<HLoadNamedField>(
8684 buffer, static_cast<HValue*>(NULL), 8668 buffer, static_cast<HValue*>(NULL),
8685 HObjectAccess::ForJSArrayBufferBackingStore()); 8669 HObjectAccess::ForJSArrayBufferBackingStore());
8686 8670
8687 HValue* typed_array_start; 8671 HValue* typed_array_start;
8688 if (is_zero_byte_offset) { 8672 if (is_zero_byte_offset) {
8689 typed_array_start = backing_store; 8673 typed_array_start = backing_store;
8690 } else { 8674 } else {
8691 HInstruction* external_pointer = 8675 HInstruction* external_pointer =
8692 AddUncasted<HAdd>(backing_store, byte_offset); 8676 AddUncasted<HAdd>(backing_store, byte_offset);
8693 // Arguments are checked prior to call to TypedArrayInitialize, 8677 // Arguments are checked prior to call to TypedArrayInitialize,
8694 // including byte_offset. 8678 // including byte_offset.
8695 external_pointer->ClearFlag(HValue::kCanOverflow); 8679 external_pointer->ClearFlag(HValue::kCanOverflow);
8696 typed_array_start = external_pointer; 8680 typed_array_start = external_pointer;
8697 } 8681 }
8698 8682
8683 Add<HStoreNamedField>(elements,
8684 HObjectAccess::ForExternalArrayExternalPointer(),
8685 typed_array_start);
8686 Add<HStoreNamedField>(elements,
8687 HObjectAccess::ForFixedArrayLength(),
8688 length);
8699 Add<HStoreNamedField>( 8689 Add<HStoreNamedField>(
8700 elements, HObjectAccess::ForExternalArrayExternalPointer(), 8690 obj, HObjectAccess::ForElementsPointer(), elements);
8701 typed_array_start, INITIALIZING_STORE);
8702 Add<HStoreNamedField>(
8703 elements, HObjectAccess::ForFixedArrayLength(), length,
8704 INITIALIZING_STORE);
8705 Add<HStoreNamedField>(
8706 obj, HObjectAccess::ForElementsPointer(), elements, INITIALIZING_STORE);
8707 } 8691 }
8708 8692
8709 if (!is_zero_byte_offset) { 8693 if (!is_zero_byte_offset) {
8710 byte_offset_smi.Else(); 8694 byte_offset_smi.Else();
8711 { // byte_offset is not Smi. 8695 { // byte_offset is not Smi.
8712 Push(Add<HPushArgument>(obj)); 8696 Push(Add<HPushArgument>(obj));
8713 VisitArgument(arguments->at(kArrayIdArg)); 8697 VisitArgument(arguments->at(kArrayIdArg));
8714 Push(Add<HPushArgument>(buffer)); 8698 Push(Add<HPushArgument>(buffer));
8715 Push(Add<HPushArgument>(byte_offset)); 8699 Push(Add<HPushArgument>(byte_offset));
8716 Push(Add<HPushArgument>(byte_length)); 8700 Push(Add<HPushArgument>(byte_length));
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
9908 HInstruction* object_elements = NULL; 9892 HInstruction* object_elements = NULL;
9909 if (elements_size > 0) { 9893 if (elements_size > 0) {
9910 HValue* object_elements_size = Add<HConstant>(elements_size); 9894 HValue* object_elements_size = Add<HConstant>(elements_size);
9911 if (boilerplate_object->HasFastDoubleElements()) { 9895 if (boilerplate_object->HasFastDoubleElements()) {
9912 // Allocation folding will not be able to fold |object| and 9896 // Allocation folding will not be able to fold |object| and
9913 // |object_elements| together if they are pre-tenured. 9897 // |object_elements| together if they are pre-tenured.
9914 if (pretenure_flag == TENURED) { 9898 if (pretenure_flag == TENURED) {
9915 HConstant* empty_fixed_array = Add<HConstant>( 9899 HConstant* empty_fixed_array = Add<HConstant>(
9916 isolate()->factory()->empty_fixed_array()); 9900 isolate()->factory()->empty_fixed_array());
9917 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 9901 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
9918 empty_fixed_array, INITIALIZING_STORE); 9902 empty_fixed_array);
9919 } 9903 }
9920 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 9904 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
9921 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current()); 9905 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current());
9922 } else { 9906 } else {
9923 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), 9907 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(),
9924 pretenure_flag, FIXED_ARRAY_TYPE, site_context->current()); 9908 pretenure_flag, FIXED_ARRAY_TYPE, site_context->current());
9925 } 9909 }
9926 } 9910 }
9927 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); 9911 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements);
9928 9912
(...skipping 18 matching lines...) Expand all
9947 ASSERT(boilerplate_object->properties()->length() == 0); 9931 ASSERT(boilerplate_object->properties()->length() == 0);
9948 9932
9949 Handle<Map> boilerplate_object_map(boilerplate_object->map()); 9933 Handle<Map> boilerplate_object_map(boilerplate_object->map());
9950 AddStoreMapConstant(object, boilerplate_object_map); 9934 AddStoreMapConstant(object, boilerplate_object_map);
9951 9935
9952 Handle<Object> properties_field = 9936 Handle<Object> properties_field =
9953 Handle<Object>(boilerplate_object->properties(), isolate()); 9937 Handle<Object>(boilerplate_object->properties(), isolate());
9954 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); 9938 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array());
9955 HInstruction* properties = Add<HConstant>(properties_field); 9939 HInstruction* properties = Add<HConstant>(properties_field);
9956 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); 9940 HObjectAccess access = HObjectAccess::ForPropertiesPointer();
9957 Add<HStoreNamedField>(object, access, properties, INITIALIZING_STORE); 9941 Add<HStoreNamedField>(object, access, properties);
9958 9942
9959 if (boilerplate_object->IsJSArray()) { 9943 if (boilerplate_object->IsJSArray()) {
9960 Handle<JSArray> boilerplate_array = 9944 Handle<JSArray> boilerplate_array =
9961 Handle<JSArray>::cast(boilerplate_object); 9945 Handle<JSArray>::cast(boilerplate_object);
9962 Handle<Object> length_field = 9946 Handle<Object> length_field =
9963 Handle<Object>(boilerplate_array->length(), isolate()); 9947 Handle<Object>(boilerplate_array->length(), isolate());
9964 HInstruction* length = Add<HConstant>(length_field); 9948 HInstruction* length = Add<HConstant>(length_field);
9965 9949
9966 ASSERT(boilerplate_array->length()->IsSmi()); 9950 ASSERT(boilerplate_array->length()->IsSmi());
9967 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( 9951 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(
9968 boilerplate_array->GetElementsKind()), length, INITIALIZING_STORE); 9952 boilerplate_array->GetElementsKind()), length);
9969 } 9953 }
9970 } 9954 }
9971 9955
9972 9956
9973 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( 9957 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader(
9974 Handle<JSObject> boilerplate_object, 9958 Handle<JSObject> boilerplate_object,
9975 HInstruction* object, 9959 HInstruction* object,
9976 HInstruction* object_elements) { 9960 HInstruction* object_elements) {
9977 ASSERT(boilerplate_object->properties()->length() == 0); 9961 ASSERT(boilerplate_object->properties()->length() == 0);
9978 if (object_elements == NULL) { 9962 if (object_elements == NULL) {
9979 Handle<Object> elements_field = 9963 Handle<Object> elements_field =
9980 Handle<Object>(boilerplate_object->elements(), isolate()); 9964 Handle<Object>(boilerplate_object->elements(), isolate());
9981 object_elements = Add<HConstant>(elements_field); 9965 object_elements = Add<HConstant>(elements_field);
9982 } 9966 }
9983 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), 9967 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
9984 object_elements, INITIALIZING_STORE); 9968 object_elements);
9985 } 9969 }
9986 9970
9987 9971
9988 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( 9972 void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
9989 Handle<JSObject> boilerplate_object, 9973 Handle<JSObject> boilerplate_object,
9990 HInstruction* object, 9974 HInstruction* object,
9991 AllocationSiteUsageContext* site_context, 9975 AllocationSiteUsageContext* site_context,
9992 PretenureFlag pretenure_flag) { 9976 PretenureFlag pretenure_flag) {
9993 Handle<DescriptorArray> descriptors( 9977 Handle<Map> boilerplate_map(boilerplate_object->map());
9994 boilerplate_object->map()->instance_descriptors()); 9978 Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors());
9995 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); 9979 int limit = boilerplate_map->NumberOfOwnDescriptors();
9996 9980
9997 int copied_fields = 0; 9981 int copied_fields = 0;
9998 for (int i = 0; i < limit; i++) { 9982 for (int i = 0; i < limit; i++) {
9999 PropertyDetails details = descriptors->GetDetails(i); 9983 PropertyDetails details = descriptors->GetDetails(i);
10000 if (details.type() != FIELD) continue; 9984 if (details.type() != FIELD) continue;
10001 copied_fields++; 9985 copied_fields++;
10002 int index = descriptors->GetFieldIndex(i); 9986 int index = descriptors->GetFieldIndex(i);
10003 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); 9987 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index);
10004 Handle<Name> name(descriptors->GetKey(i)); 9988 Handle<Name> name(descriptors->GetKey(i));
10005 Handle<Object> value = 9989 Handle<Object> value =
10006 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), 9990 Handle<Object>(boilerplate_object->InObjectPropertyAt(index),
10007 isolate()); 9991 isolate());
10008 9992
10009 // The access for the store depends on the type of the boilerplate. 9993 // The access for the store depends on the type of the boilerplate.
10010 HObjectAccess access = boilerplate_object->IsJSArray() ? 9994 HObjectAccess access = boilerplate_object->IsJSArray() ?
10011 HObjectAccess::ForJSArrayOffset(property_offset) : 9995 HObjectAccess::ForJSArrayOffset(property_offset) :
10012 HObjectAccess::ForJSObjectOffset(property_offset); 9996 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset);
10013 9997
10014 if (value->IsJSObject()) { 9998 if (value->IsJSObject()) {
10015 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 9999 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
10016 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 10000 Handle<AllocationSite> current_site = site_context->EnterNewScope();
10017 HInstruction* result = 10001 HInstruction* result =
10018 BuildFastLiteral(value_object, site_context); 10002 BuildFastLiteral(value_object, site_context);
10019 site_context->ExitScope(current_site, value_object); 10003 site_context->ExitScope(current_site, value_object);
10020 Add<HStoreNamedField>(object, access, result, INITIALIZING_STORE); 10004 Add<HStoreNamedField>(object, access, result);
10021 } else { 10005 } else {
10022 Representation representation = details.representation(); 10006 Representation representation = details.representation();
10023 HInstruction* value_instruction; 10007 HInstruction* value_instruction;
10024 10008
10025 if (representation.IsDouble()) { 10009 if (representation.IsDouble()) {
10026 // Allocate a HeapNumber box and store the value into it. 10010 // Allocate a HeapNumber box and store the value into it.
10027 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); 10011 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize);
10028 // This heap number alloc does not have a corresponding 10012 // This heap number alloc does not have a corresponding
10029 // AllocationSite. That is okay because 10013 // AllocationSite. That is okay because
10030 // 1) it's a child object of another object with a valid allocation site 10014 // 1) it's a child object of another object with a valid allocation site
10031 // 2) we can just use the mode of the parent object for pretenuring 10015 // 2) we can just use the mode of the parent object for pretenuring
10032 HInstruction* double_box = 10016 HInstruction* double_box =
10033 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), 10017 Add<HAllocate>(heap_number_constant, HType::HeapNumber(),
10034 pretenure_flag, HEAP_NUMBER_TYPE); 10018 pretenure_flag, HEAP_NUMBER_TYPE);
10035 AddStoreMapConstant(double_box, 10019 AddStoreMapConstant(double_box,
10036 isolate()->factory()->heap_number_map()); 10020 isolate()->factory()->heap_number_map());
10037 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), 10021 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(),
10038 Add<HConstant>(value), INITIALIZING_STORE); 10022 Add<HConstant>(value));
10039 value_instruction = double_box; 10023 value_instruction = double_box;
10040 } else if (representation.IsSmi() && value->IsUninitialized()) { 10024 } else if (representation.IsSmi() && value->IsUninitialized()) {
10041 value_instruction = graph()->GetConstant0(); 10025 value_instruction = graph()->GetConstant0();
10042 } else { 10026 } else {
10043 value_instruction = Add<HConstant>(value); 10027 value_instruction = Add<HConstant>(value);
10044 } 10028 }
10045 10029
10046 Add<HStoreNamedField>(object, access, value_instruction, 10030 Add<HStoreNamedField>(object, access, value_instruction);
10047 INITIALIZING_STORE);
10048 } 10031 }
10049 } 10032 }
10050 10033
10051 int inobject_properties = boilerplate_object->map()->inobject_properties(); 10034 int inobject_properties = boilerplate_object->map()->inobject_properties();
10052 HInstruction* value_instruction = 10035 HInstruction* value_instruction =
10053 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); 10036 Add<HConstant>(isolate()->factory()->one_pointer_filler_map());
10054 for (int i = copied_fields; i < inobject_properties; i++) { 10037 for (int i = copied_fields; i < inobject_properties; i++) {
10055 ASSERT(boilerplate_object->IsJSObject()); 10038 ASSERT(boilerplate_object->IsJSObject());
10056 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); 10039 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i);
10057 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); 10040 HObjectAccess access =
10058 Add<HStoreNamedField>(object, access, value_instruction, 10041 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset);
10059 PREINITIALIZING_STORE); 10042 Add<HStoreNamedField>(object, access, value_instruction);
10060 } 10043 }
10061 } 10044 }
10062 10045
10063 10046
10064 void HOptimizedGraphBuilder::BuildEmitElements( 10047 void HOptimizedGraphBuilder::BuildEmitElements(
10065 Handle<JSObject> boilerplate_object, 10048 Handle<JSObject> boilerplate_object,
10066 Handle<FixedArrayBase> elements, 10049 Handle<FixedArrayBase> elements,
10067 HValue* object_elements, 10050 HValue* object_elements,
10068 AllocationSiteUsageContext* site_context) { 10051 AllocationSiteUsageContext* site_context) {
10069 ElementsKind kind = boilerplate_object->map()->elements_kind(); 10052 ElementsKind kind = boilerplate_object->map()->elements_kind();
(...skipping 19 matching lines...) Expand all
10089 HValue* object_elements) { 10072 HValue* object_elements) {
10090 HInstruction* boilerplate_elements = Add<HConstant>(elements); 10073 HInstruction* boilerplate_elements = Add<HConstant>(elements);
10091 int elements_length = elements->length(); 10074 int elements_length = elements->length();
10092 for (int i = 0; i < elements_length; i++) { 10075 for (int i = 0; i < elements_length; i++) {
10093 HValue* key_constant = Add<HConstant>(i); 10076 HValue* key_constant = Add<HConstant>(i);
10094 HInstruction* value_instruction = 10077 HInstruction* value_instruction =
10095 Add<HLoadKeyed>(boilerplate_elements, key_constant, 10078 Add<HLoadKeyed>(boilerplate_elements, key_constant,
10096 static_cast<HValue*>(NULL), kind, 10079 static_cast<HValue*>(NULL), kind,
10097 ALLOW_RETURN_HOLE); 10080 ALLOW_RETURN_HOLE);
10098 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, 10081 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant,
10099 value_instruction, kind, 10082 value_instruction, kind);
10100 INITIALIZING_STORE);
10101 store->SetFlag(HValue::kAllowUndefinedAsNaN); 10083 store->SetFlag(HValue::kAllowUndefinedAsNaN);
10102 } 10084 }
10103 } 10085 }
10104 10086
10105 10087
10106 void HOptimizedGraphBuilder::BuildEmitFixedArray( 10088 void HOptimizedGraphBuilder::BuildEmitFixedArray(
10107 Handle<FixedArrayBase> elements, 10089 Handle<FixedArrayBase> elements,
10108 ElementsKind kind, 10090 ElementsKind kind,
10109 HValue* object_elements, 10091 HValue* object_elements,
10110 AllocationSiteUsageContext* site_context) { 10092 AllocationSiteUsageContext* site_context) {
10111 HInstruction* boilerplate_elements = Add<HConstant>(elements); 10093 HInstruction* boilerplate_elements = Add<HConstant>(elements);
10112 int elements_length = elements->length(); 10094 int elements_length = elements->length();
10113 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); 10095 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
10114 for (int i = 0; i < elements_length; i++) { 10096 for (int i = 0; i < elements_length; i++) {
10115 Handle<Object> value(fast_elements->get(i), isolate()); 10097 Handle<Object> value(fast_elements->get(i), isolate());
10116 HValue* key_constant = Add<HConstant>(i); 10098 HValue* key_constant = Add<HConstant>(i);
10117 if (value->IsJSObject()) { 10099 if (value->IsJSObject()) {
10118 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 10100 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
10119 Handle<AllocationSite> current_site = site_context->EnterNewScope(); 10101 Handle<AllocationSite> current_site = site_context->EnterNewScope();
10120 HInstruction* result = 10102 HInstruction* result =
10121 BuildFastLiteral(value_object, site_context); 10103 BuildFastLiteral(value_object, site_context);
10122 site_context->ExitScope(current_site, value_object); 10104 site_context->ExitScope(current_site, value_object);
10123 Add<HStoreKeyed>(object_elements, key_constant, result, kind, 10105 Add<HStoreKeyed>(object_elements, key_constant, result, kind);
10124 INITIALIZING_STORE);
10125 } else { 10106 } else {
10126 HInstruction* value_instruction = 10107 HInstruction* value_instruction =
10127 Add<HLoadKeyed>(boilerplate_elements, key_constant, 10108 Add<HLoadKeyed>(boilerplate_elements, key_constant,
10128 static_cast<HValue*>(NULL), kind, 10109 static_cast<HValue*>(NULL), kind,
10129 ALLOW_RETURN_HOLE); 10110 ALLOW_RETURN_HOLE);
10130 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind, 10111 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind);
10131 INITIALIZING_STORE);
10132 } 10112 }
10133 } 10113 }
10134 } 10114 }
10135 10115
10136 10116
10137 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { 10117 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) {
10138 ASSERT(!HasStackOverflow()); 10118 ASSERT(!HasStackOverflow());
10139 ASSERT(current_block() != NULL); 10119 ASSERT(current_block() != NULL);
10140 ASSERT(current_block()->HasPredecessor()); 10120 ASSERT(current_block()->HasPredecessor());
10141 HInstruction* instr = BuildThisFunction(); 10121 HInstruction* instr = BuildThisFunction();
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
10439 HValue* object = Pop(); 10419 HValue* object = Pop();
10440 10420
10441 IfBuilder if_objectisvalue(this); 10421 IfBuilder if_objectisvalue(this);
10442 HValue* objectisvalue = if_objectisvalue.If<HHasInstanceTypeAndBranch>( 10422 HValue* objectisvalue = if_objectisvalue.If<HHasInstanceTypeAndBranch>(
10443 object, JS_VALUE_TYPE); 10423 object, JS_VALUE_TYPE);
10444 if_objectisvalue.Then(); 10424 if_objectisvalue.Then();
10445 { 10425 {
10446 // Return the actual value. 10426 // Return the actual value.
10447 Push(Add<HLoadNamedField>( 10427 Push(Add<HLoadNamedField>(
10448 object, objectisvalue, 10428 object, objectisvalue,
10449 HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset))); 10429 HObjectAccess::ForObservableJSObjectOffset(
10430 JSValue::kValueOffset)));
10450 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10431 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10451 } 10432 }
10452 if_objectisvalue.Else(); 10433 if_objectisvalue.Else();
10453 { 10434 {
10454 // If the object is not a value return the object. 10435 // If the object is not a value return the object.
10455 Push(object); 10436 Push(object);
10456 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10437 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10457 } 10438 }
10458 if_objectisvalue.End(); 10439 if_objectisvalue.End();
10459 return ast_context()->ReturnValue(Pop()); 10440 return ast_context()->ReturnValue(Pop());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
10509 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 10490 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
10510 HValue* value = Pop(); 10491 HValue* value = Pop();
10511 HValue* object = Pop(); 10492 HValue* object = Pop();
10512 10493
10513 // Check if object is a JSValue. 10494 // Check if object is a JSValue.
10514 IfBuilder if_objectisvalue(this); 10495 IfBuilder if_objectisvalue(this);
10515 if_objectisvalue.If<HHasInstanceTypeAndBranch>(object, JS_VALUE_TYPE); 10496 if_objectisvalue.If<HHasInstanceTypeAndBranch>(object, JS_VALUE_TYPE);
10516 if_objectisvalue.Then(); 10497 if_objectisvalue.Then();
10517 { 10498 {
10518 // Create in-object property store to kValueOffset. 10499 // Create in-object property store to kValueOffset.
10519 Add<HStoreNamedField>( 10500 Add<HStoreNamedField>(object,
10520 object, HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), 10501 HObjectAccess::ForObservableJSObjectOffset(JSValue::kValueOffset),
10521 value, INITIALIZING_STORE); 10502 value);
10522 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10503 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10523 } 10504 }
10524 if_objectisvalue.Else(); 10505 if_objectisvalue.Else();
10525 { 10506 {
10526 // Nothing to do in this case. 10507 // Nothing to do in this case.
10527 Add<HSimulate>(call->id(), FIXED_SIMULATE); 10508 Add<HSimulate>(call->id(), FIXED_SIMULATE);
10528 } 10509 }
10529 if_objectisvalue.End(); 10510 if_objectisvalue.End();
10530 return ast_context()->ReturnValue(value); 10511 return ast_context()->ReturnValue(value);
10531 } 10512 }
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
11376 if (ShouldProduceTraceOutput()) { 11357 if (ShouldProduceTraceOutput()) {
11377 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11358 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11378 } 11359 }
11379 11360
11380 #ifdef DEBUG 11361 #ifdef DEBUG
11381 graph_->Verify(false); // No full verify. 11362 graph_->Verify(false); // No full verify.
11382 #endif 11363 #endif
11383 } 11364 }
11384 11365
11385 } } // namespace v8::internal 11366 } } // 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