OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 in some cases, so initialize | 9897 // |object_elements| together in some cases, so initialize |
9914 // elements with the undefined to make GC happy. | 9898 // elements with the undefined to make GC happy. |
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 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), | 9903 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), |
9920 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current()); | 9904 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current()); |
9921 } else { | 9905 } else { |
9922 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), | 9906 object_elements = Add<HAllocate>(object_elements_size, HType::JSObject(), |
9923 pretenure_flag, FIXED_ARRAY_TYPE, site_context->current()); | 9907 pretenure_flag, FIXED_ARRAY_TYPE, site_context->current()); |
9924 } | 9908 } |
9925 } | 9909 } |
9926 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); | 9910 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); |
9927 | 9911 |
9928 // Copy object elements if non-COW. | 9912 // Copy object elements if non-COW. |
(...skipping 17 matching lines...) Expand all Loading... |
9946 ASSERT(boilerplate_object->properties()->length() == 0); | 9930 ASSERT(boilerplate_object->properties()->length() == 0); |
9947 | 9931 |
9948 Handle<Map> boilerplate_object_map(boilerplate_object->map()); | 9932 Handle<Map> boilerplate_object_map(boilerplate_object->map()); |
9949 AddStoreMapConstant(object, boilerplate_object_map); | 9933 AddStoreMapConstant(object, boilerplate_object_map); |
9950 | 9934 |
9951 Handle<Object> properties_field = | 9935 Handle<Object> properties_field = |
9952 Handle<Object>(boilerplate_object->properties(), isolate()); | 9936 Handle<Object>(boilerplate_object->properties(), isolate()); |
9953 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); | 9937 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); |
9954 HInstruction* properties = Add<HConstant>(properties_field); | 9938 HInstruction* properties = Add<HConstant>(properties_field); |
9955 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 9939 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
9956 Add<HStoreNamedField>(object, access, properties, INITIALIZING_STORE); | 9940 Add<HStoreNamedField>(object, access, properties); |
9957 | 9941 |
9958 if (boilerplate_object->IsJSArray()) { | 9942 if (boilerplate_object->IsJSArray()) { |
9959 Handle<JSArray> boilerplate_array = | 9943 Handle<JSArray> boilerplate_array = |
9960 Handle<JSArray>::cast(boilerplate_object); | 9944 Handle<JSArray>::cast(boilerplate_object); |
9961 Handle<Object> length_field = | 9945 Handle<Object> length_field = |
9962 Handle<Object>(boilerplate_array->length(), isolate()); | 9946 Handle<Object>(boilerplate_array->length(), isolate()); |
9963 HInstruction* length = Add<HConstant>(length_field); | 9947 HInstruction* length = Add<HConstant>(length_field); |
9964 | 9948 |
9965 ASSERT(boilerplate_array->length()->IsSmi()); | 9949 ASSERT(boilerplate_array->length()->IsSmi()); |
9966 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( | 9950 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( |
9967 boilerplate_array->GetElementsKind()), length, INITIALIZING_STORE); | 9951 boilerplate_array->GetElementsKind()), length); |
9968 } | 9952 } |
9969 } | 9953 } |
9970 | 9954 |
9971 | 9955 |
9972 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( | 9956 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( |
9973 Handle<JSObject> boilerplate_object, | 9957 Handle<JSObject> boilerplate_object, |
9974 HInstruction* object, | 9958 HInstruction* object, |
9975 HInstruction* object_elements) { | 9959 HInstruction* object_elements) { |
9976 ASSERT(boilerplate_object->properties()->length() == 0); | 9960 ASSERT(boilerplate_object->properties()->length() == 0); |
9977 if (object_elements == NULL) { | 9961 if (object_elements == NULL) { |
9978 Handle<Object> elements_field = | 9962 Handle<Object> elements_field = |
9979 Handle<Object>(boilerplate_object->elements(), isolate()); | 9963 Handle<Object>(boilerplate_object->elements(), isolate()); |
9980 object_elements = Add<HConstant>(elements_field); | 9964 object_elements = Add<HConstant>(elements_field); |
9981 } | 9965 } |
9982 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 9966 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
9983 object_elements, INITIALIZING_STORE); | 9967 object_elements); |
9984 } | 9968 } |
9985 | 9969 |
9986 | 9970 |
9987 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( | 9971 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( |
9988 Handle<JSObject> boilerplate_object, | 9972 Handle<JSObject> boilerplate_object, |
9989 HInstruction* object, | 9973 HInstruction* object, |
9990 AllocationSiteUsageContext* site_context, | 9974 AllocationSiteUsageContext* site_context, |
9991 PretenureFlag pretenure_flag) { | 9975 PretenureFlag pretenure_flag) { |
9992 Handle<DescriptorArray> descriptors( | 9976 Handle<Map> boilerplate_map(boilerplate_object->map()); |
9993 boilerplate_object->map()->instance_descriptors()); | 9977 Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors()); |
9994 int limit = boilerplate_object->map()->NumberOfOwnDescriptors(); | 9978 int limit = boilerplate_map->NumberOfOwnDescriptors(); |
9995 | 9979 |
9996 int copied_fields = 0; | 9980 int copied_fields = 0; |
9997 for (int i = 0; i < limit; i++) { | 9981 for (int i = 0; i < limit; i++) { |
9998 PropertyDetails details = descriptors->GetDetails(i); | 9982 PropertyDetails details = descriptors->GetDetails(i); |
9999 if (details.type() != FIELD) continue; | 9983 if (details.type() != FIELD) continue; |
10000 copied_fields++; | 9984 copied_fields++; |
10001 int index = descriptors->GetFieldIndex(i); | 9985 int index = descriptors->GetFieldIndex(i); |
10002 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); | 9986 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); |
10003 Handle<Name> name(descriptors->GetKey(i)); | 9987 Handle<Name> name(descriptors->GetKey(i)); |
10004 Handle<Object> value = | 9988 Handle<Object> value = |
10005 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), | 9989 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), |
10006 isolate()); | 9990 isolate()); |
10007 | 9991 |
10008 // The access for the store depends on the type of the boilerplate. | 9992 // The access for the store depends on the type of the boilerplate. |
10009 HObjectAccess access = boilerplate_object->IsJSArray() ? | 9993 HObjectAccess access = boilerplate_object->IsJSArray() ? |
10010 HObjectAccess::ForJSArrayOffset(property_offset) : | 9994 HObjectAccess::ForJSArrayOffset(property_offset) : |
10011 HObjectAccess::ForJSObjectOffset(property_offset); | 9995 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); |
10012 | 9996 |
10013 if (value->IsJSObject()) { | 9997 if (value->IsJSObject()) { |
10014 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9998 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
10015 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 9999 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
10016 HInstruction* result = | 10000 HInstruction* result = |
10017 BuildFastLiteral(value_object, site_context); | 10001 BuildFastLiteral(value_object, site_context); |
10018 site_context->ExitScope(current_site, value_object); | 10002 site_context->ExitScope(current_site, value_object); |
10019 Add<HStoreNamedField>(object, access, result, INITIALIZING_STORE); | 10003 Add<HStoreNamedField>(object, access, result); |
10020 } else { | 10004 } else { |
10021 Representation representation = details.representation(); | 10005 Representation representation = details.representation(); |
10022 HInstruction* value_instruction; | 10006 HInstruction* value_instruction; |
10023 | 10007 |
10024 if (representation.IsDouble()) { | 10008 if (representation.IsDouble()) { |
10025 // Allocate a HeapNumber box and store the value into it. | 10009 // Allocate a HeapNumber box and store the value into it. |
10026 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); | 10010 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); |
10027 // This heap number alloc does not have a corresponding | 10011 // This heap number alloc does not have a corresponding |
10028 // AllocationSite. That is okay because | 10012 // AllocationSite. That is okay because |
10029 // 1) it's a child object of another object with a valid allocation site | 10013 // 1) it's a child object of another object with a valid allocation site |
10030 // 2) we can just use the mode of the parent object for pretenuring | 10014 // 2) we can just use the mode of the parent object for pretenuring |
10031 HInstruction* double_box = | 10015 HInstruction* double_box = |
10032 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), | 10016 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), |
10033 pretenure_flag, HEAP_NUMBER_TYPE); | 10017 pretenure_flag, HEAP_NUMBER_TYPE); |
10034 AddStoreMapConstant(double_box, | 10018 AddStoreMapConstant(double_box, |
10035 isolate()->factory()->heap_number_map()); | 10019 isolate()->factory()->heap_number_map()); |
10036 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), | 10020 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), |
10037 Add<HConstant>(value), INITIALIZING_STORE); | 10021 Add<HConstant>(value)); |
10038 value_instruction = double_box; | 10022 value_instruction = double_box; |
10039 } else if (representation.IsSmi() && value->IsUninitialized()) { | 10023 } else if (representation.IsSmi() && value->IsUninitialized()) { |
10040 value_instruction = graph()->GetConstant0(); | 10024 value_instruction = graph()->GetConstant0(); |
10041 } else { | 10025 } else { |
10042 value_instruction = Add<HConstant>(value); | 10026 value_instruction = Add<HConstant>(value); |
10043 } | 10027 } |
10044 | 10028 |
10045 Add<HStoreNamedField>(object, access, value_instruction, | 10029 Add<HStoreNamedField>(object, access, value_instruction); |
10046 INITIALIZING_STORE); | |
10047 } | 10030 } |
10048 } | 10031 } |
10049 | 10032 |
10050 int inobject_properties = boilerplate_object->map()->inobject_properties(); | 10033 int inobject_properties = boilerplate_object->map()->inobject_properties(); |
10051 HInstruction* value_instruction = | 10034 HInstruction* value_instruction = |
10052 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); | 10035 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); |
10053 for (int i = copied_fields; i < inobject_properties; i++) { | 10036 for (int i = copied_fields; i < inobject_properties; i++) { |
10054 ASSERT(boilerplate_object->IsJSObject()); | 10037 ASSERT(boilerplate_object->IsJSObject()); |
10055 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); | 10038 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); |
10056 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); | 10039 HObjectAccess access = |
10057 Add<HStoreNamedField>(object, access, value_instruction, | 10040 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); |
10058 PREINITIALIZING_STORE); | 10041 Add<HStoreNamedField>(object, access, value_instruction); |
10059 } | 10042 } |
10060 } | 10043 } |
10061 | 10044 |
10062 | 10045 |
10063 void HOptimizedGraphBuilder::BuildEmitElements( | 10046 void HOptimizedGraphBuilder::BuildEmitElements( |
10064 Handle<JSObject> boilerplate_object, | 10047 Handle<JSObject> boilerplate_object, |
10065 Handle<FixedArrayBase> elements, | 10048 Handle<FixedArrayBase> elements, |
10066 HValue* object_elements, | 10049 HValue* object_elements, |
10067 AllocationSiteUsageContext* site_context) { | 10050 AllocationSiteUsageContext* site_context) { |
10068 ElementsKind kind = boilerplate_object->map()->elements_kind(); | 10051 ElementsKind kind = boilerplate_object->map()->elements_kind(); |
(...skipping 19 matching lines...) Expand all Loading... |
10088 HValue* object_elements) { | 10071 HValue* object_elements) { |
10089 HInstruction* boilerplate_elements = Add<HConstant>(elements); | 10072 HInstruction* boilerplate_elements = Add<HConstant>(elements); |
10090 int elements_length = elements->length(); | 10073 int elements_length = elements->length(); |
10091 for (int i = 0; i < elements_length; i++) { | 10074 for (int i = 0; i < elements_length; i++) { |
10092 HValue* key_constant = Add<HConstant>(i); | 10075 HValue* key_constant = Add<HConstant>(i); |
10093 HInstruction* value_instruction = | 10076 HInstruction* value_instruction = |
10094 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 10077 Add<HLoadKeyed>(boilerplate_elements, key_constant, |
10095 static_cast<HValue*>(NULL), kind, | 10078 static_cast<HValue*>(NULL), kind, |
10096 ALLOW_RETURN_HOLE); | 10079 ALLOW_RETURN_HOLE); |
10097 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, | 10080 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, |
10098 value_instruction, kind, | 10081 value_instruction, kind); |
10099 INITIALIZING_STORE); | |
10100 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 10082 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
10101 } | 10083 } |
10102 } | 10084 } |
10103 | 10085 |
10104 | 10086 |
10105 void HOptimizedGraphBuilder::BuildEmitFixedArray( | 10087 void HOptimizedGraphBuilder::BuildEmitFixedArray( |
10106 Handle<FixedArrayBase> elements, | 10088 Handle<FixedArrayBase> elements, |
10107 ElementsKind kind, | 10089 ElementsKind kind, |
10108 HValue* object_elements, | 10090 HValue* object_elements, |
10109 AllocationSiteUsageContext* site_context) { | 10091 AllocationSiteUsageContext* site_context) { |
10110 HInstruction* boilerplate_elements = Add<HConstant>(elements); | 10092 HInstruction* boilerplate_elements = Add<HConstant>(elements); |
10111 int elements_length = elements->length(); | 10093 int elements_length = elements->length(); |
10112 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); | 10094 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); |
10113 for (int i = 0; i < elements_length; i++) { | 10095 for (int i = 0; i < elements_length; i++) { |
10114 Handle<Object> value(fast_elements->get(i), isolate()); | 10096 Handle<Object> value(fast_elements->get(i), isolate()); |
10115 HValue* key_constant = Add<HConstant>(i); | 10097 HValue* key_constant = Add<HConstant>(i); |
10116 if (value->IsJSObject()) { | 10098 if (value->IsJSObject()) { |
10117 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 10099 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
10118 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 10100 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
10119 HInstruction* result = | 10101 HInstruction* result = |
10120 BuildFastLiteral(value_object, site_context); | 10102 BuildFastLiteral(value_object, site_context); |
10121 site_context->ExitScope(current_site, value_object); | 10103 site_context->ExitScope(current_site, value_object); |
10122 Add<HStoreKeyed>(object_elements, key_constant, result, kind, | 10104 Add<HStoreKeyed>(object_elements, key_constant, result, kind); |
10123 INITIALIZING_STORE); | |
10124 } else { | 10105 } else { |
10125 HInstruction* value_instruction = | 10106 HInstruction* value_instruction = |
10126 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 10107 Add<HLoadKeyed>(boilerplate_elements, key_constant, |
10127 static_cast<HValue*>(NULL), kind, | 10108 static_cast<HValue*>(NULL), kind, |
10128 ALLOW_RETURN_HOLE); | 10109 ALLOW_RETURN_HOLE); |
10129 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind, | 10110 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); |
10130 INITIALIZING_STORE); | |
10131 } | 10111 } |
10132 } | 10112 } |
10133 } | 10113 } |
10134 | 10114 |
10135 | 10115 |
10136 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 10116 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
10137 ASSERT(!HasStackOverflow()); | 10117 ASSERT(!HasStackOverflow()); |
10138 ASSERT(current_block() != NULL); | 10118 ASSERT(current_block() != NULL); |
10139 ASSERT(current_block()->HasPredecessor()); | 10119 ASSERT(current_block()->HasPredecessor()); |
10140 HInstruction* instr = BuildThisFunction(); | 10120 HInstruction* instr = BuildThisFunction(); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10438 HValue* object = Pop(); | 10418 HValue* object = Pop(); |
10439 | 10419 |
10440 IfBuilder if_objectisvalue(this); | 10420 IfBuilder if_objectisvalue(this); |
10441 HValue* objectisvalue = if_objectisvalue.If<HHasInstanceTypeAndBranch>( | 10421 HValue* objectisvalue = if_objectisvalue.If<HHasInstanceTypeAndBranch>( |
10442 object, JS_VALUE_TYPE); | 10422 object, JS_VALUE_TYPE); |
10443 if_objectisvalue.Then(); | 10423 if_objectisvalue.Then(); |
10444 { | 10424 { |
10445 // Return the actual value. | 10425 // Return the actual value. |
10446 Push(Add<HLoadNamedField>( | 10426 Push(Add<HLoadNamedField>( |
10447 object, objectisvalue, | 10427 object, objectisvalue, |
10448 HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset))); | 10428 HObjectAccess::ForObservableJSObjectOffset( |
| 10429 JSValue::kValueOffset))); |
10449 Add<HSimulate>(call->id(), FIXED_SIMULATE); | 10430 Add<HSimulate>(call->id(), FIXED_SIMULATE); |
10450 } | 10431 } |
10451 if_objectisvalue.Else(); | 10432 if_objectisvalue.Else(); |
10452 { | 10433 { |
10453 // If the object is not a value return the object. | 10434 // If the object is not a value return the object. |
10454 Push(object); | 10435 Push(object); |
10455 Add<HSimulate>(call->id(), FIXED_SIMULATE); | 10436 Add<HSimulate>(call->id(), FIXED_SIMULATE); |
10456 } | 10437 } |
10457 if_objectisvalue.End(); | 10438 if_objectisvalue.End(); |
10458 return ast_context()->ReturnValue(Pop()); | 10439 return ast_context()->ReturnValue(Pop()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10508 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 10489 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
10509 HValue* value = Pop(); | 10490 HValue* value = Pop(); |
10510 HValue* object = Pop(); | 10491 HValue* object = Pop(); |
10511 | 10492 |
10512 // Check if object is a JSValue. | 10493 // Check if object is a JSValue. |
10513 IfBuilder if_objectisvalue(this); | 10494 IfBuilder if_objectisvalue(this); |
10514 if_objectisvalue.If<HHasInstanceTypeAndBranch>(object, JS_VALUE_TYPE); | 10495 if_objectisvalue.If<HHasInstanceTypeAndBranch>(object, JS_VALUE_TYPE); |
10515 if_objectisvalue.Then(); | 10496 if_objectisvalue.Then(); |
10516 { | 10497 { |
10517 // Create in-object property store to kValueOffset. | 10498 // Create in-object property store to kValueOffset. |
10518 Add<HStoreNamedField>( | 10499 Add<HStoreNamedField>(object, |
10519 object, HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), | 10500 HObjectAccess::ForObservableJSObjectOffset(JSValue::kValueOffset), |
10520 value, INITIALIZING_STORE); | 10501 value); |
10521 Add<HSimulate>(call->id(), FIXED_SIMULATE); | 10502 Add<HSimulate>(call->id(), FIXED_SIMULATE); |
10522 } | 10503 } |
10523 if_objectisvalue.Else(); | 10504 if_objectisvalue.Else(); |
10524 { | 10505 { |
10525 // Nothing to do in this case. | 10506 // Nothing to do in this case. |
10526 Add<HSimulate>(call->id(), FIXED_SIMULATE); | 10507 Add<HSimulate>(call->id(), FIXED_SIMULATE); |
10527 } | 10508 } |
10528 if_objectisvalue.End(); | 10509 if_objectisvalue.End(); |
10529 return ast_context()->ReturnValue(value); | 10510 return ast_context()->ReturnValue(value); |
10530 } | 10511 } |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11375 if (ShouldProduceTraceOutput()) { | 11356 if (ShouldProduceTraceOutput()) { |
11376 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11357 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11377 } | 11358 } |
11378 | 11359 |
11379 #ifdef DEBUG | 11360 #ifdef DEBUG |
11380 graph_->Verify(false); // No full verify. | 11361 graph_->Verify(false); // No full verify. |
11381 #endif | 11362 #endif |
11382 } | 11363 } |
11383 | 11364 |
11384 } } // namespace v8::internal | 11365 } } // namespace v8::internal |
OLD | NEW |