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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 | 1192 |
1193 | 1193 |
1194 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) { | 1194 void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) { |
1195 if (FLAG_native_code_counters && counter->Enabled()) { | 1195 if (FLAG_native_code_counters && counter->Enabled()) { |
1196 HValue* reference = Add<HConstant>(ExternalReference(counter)); | 1196 HValue* reference = Add<HConstant>(ExternalReference(counter)); |
1197 HValue* old_value = Add<HLoadNamedField>(reference, | 1197 HValue* old_value = Add<HLoadNamedField>(reference, |
1198 HObjectAccess::ForCounter()); | 1198 HObjectAccess::ForCounter()); |
1199 HValue* new_value = AddUncasted<HAdd>(old_value, graph()->GetConstant1()); | 1199 HValue* new_value = AddUncasted<HAdd>(old_value, graph()->GetConstant1()); |
1200 new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow | 1200 new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow |
1201 Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(), | 1201 Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(), |
1202 new_value); | 1202 new_value, STORE_TO_INITIALIZED_ENTRY); |
1203 } | 1203 } |
1204 } | 1204 } |
1205 | 1205 |
1206 | 1206 |
1207 void HGraphBuilder::AddSimulate(BailoutId id, | 1207 void HGraphBuilder::AddSimulate(BailoutId id, |
1208 RemovableSimulate removable) { | 1208 RemovableSimulate removable) { |
1209 ASSERT(current_block() != NULL); | 1209 ASSERT(current_block() != NULL); |
1210 ASSERT(!graph()->IsInsideNoSideEffectsScope()); | 1210 ASSERT(!graph()->IsInsideNoSideEffectsScope()); |
1211 current_block()->AddNewSimulate(id, position_, removable); | 1211 current_block()->AddNewSimulate(id, position_, removable); |
1212 } | 1212 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 capacity_checker.Else(); | 1330 capacity_checker.Else(); |
1331 | 1331 |
1332 environment()->Push(elements); | 1332 environment()->Push(elements); |
1333 capacity_checker.End(); | 1333 capacity_checker.End(); |
1334 | 1334 |
1335 if (is_js_array) { | 1335 if (is_js_array) { |
1336 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); | 1336 HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); |
1337 new_length->ClearFlag(HValue::kCanOverflow); | 1337 new_length->ClearFlag(HValue::kCanOverflow); |
1338 | 1338 |
1339 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), | 1339 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), |
1340 new_length); | 1340 new_length, INITIALIZING_STORE); |
1341 } | 1341 } |
1342 | 1342 |
1343 if (is_store && kind == FAST_SMI_ELEMENTS) { | 1343 if (is_store && kind == FAST_SMI_ELEMENTS) { |
1344 HValue* checked_elements = environment()->Top(); | 1344 HValue* checked_elements = environment()->Top(); |
1345 | 1345 |
1346 // Write zero to ensure that the new element is initialized with some smi. | 1346 // Write zero to ensure that the new element is initialized with some smi. |
1347 Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind); | 1347 Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind, |
| 1348 INITIALIZING_STORE); |
1348 } | 1349 } |
1349 | 1350 |
1350 length_checker.Else(); | 1351 length_checker.Else(); |
1351 Add<HBoundsCheck>(key, length); | 1352 Add<HBoundsCheck>(key, length); |
1352 | 1353 |
1353 environment()->Push(elements); | 1354 environment()->Push(elements); |
1354 length_checker.End(); | 1355 length_checker.End(); |
1355 | 1356 |
1356 return environment()->Pop(); | 1357 return environment()->Pop(); |
1357 } | 1358 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 HInstruction* array_length = is_jsarray | 1415 HInstruction* array_length = is_jsarray |
1415 ? Add<HLoadNamedField>(object, HObjectAccess::ForArrayLength(from_kind)) | 1416 ? Add<HLoadNamedField>(object, HObjectAccess::ForArrayLength(from_kind)) |
1416 : elements_length; | 1417 : elements_length; |
1417 | 1418 |
1418 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, | 1419 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, |
1419 array_length, elements_length); | 1420 array_length, elements_length); |
1420 | 1421 |
1421 if_builder.End(); | 1422 if_builder.End(); |
1422 } | 1423 } |
1423 | 1424 |
1424 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map); | 1425 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map, |
| 1426 INITIALIZING_STORE); |
1425 } | 1427 } |
1426 | 1428 |
1427 | 1429 |
1428 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper( | 1430 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper( |
1429 HValue* elements, | 1431 HValue* elements, |
1430 HValue* key, | 1432 HValue* key, |
1431 HValue* hash, | 1433 HValue* hash, |
1432 HValue* mask, | 1434 HValue* mask, |
1433 int current_probe) { | 1435 int current_probe) { |
1434 if (current_probe == kNumberDictionaryProbes) { | 1436 if (current_probe == kNumberDictionaryProbes) { |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 if_onebyte.Else(); | 1803 if_onebyte.Else(); |
1802 { | 1804 { |
1803 // We can safely skip the write barrier for storing the map here. | 1805 // We can safely skip the write barrier for storing the map here. |
1804 Handle<Map> map = isolate()->factory()->cons_string_map(); | 1806 Handle<Map> map = isolate()->factory()->cons_string_map(); |
1805 AddStoreMapConstantNoWriteBarrier(result, map); | 1807 AddStoreMapConstantNoWriteBarrier(result, map); |
1806 } | 1808 } |
1807 if_onebyte.End(); | 1809 if_onebyte.End(); |
1808 | 1810 |
1809 // Initialize the cons string fields. | 1811 // Initialize the cons string fields. |
1810 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), | 1812 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), |
1811 Add<HConstant>(String::kEmptyHashField)); | 1813 Add<HConstant>(String::kEmptyHashField), |
1812 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length); | 1814 INITIALIZING_STORE); |
1813 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left); | 1815 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length, |
1814 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right); | 1816 INITIALIZING_STORE); |
| 1817 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left, |
| 1818 INITIALIZING_STORE); |
| 1819 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right, |
| 1820 INITIALIZING_STORE); |
1815 | 1821 |
1816 // Count the native string addition. | 1822 // Count the native string addition. |
1817 AddIncrementCounter(isolate()->counters()->string_add_native()); | 1823 AddIncrementCounter(isolate()->counters()->string_add_native()); |
1818 | 1824 |
1819 return result; | 1825 return result; |
1820 } | 1826 } |
1821 | 1827 |
1822 | 1828 |
1823 void HGraphBuilder::BuildCopySeqStringChars(HValue* src, | 1829 void HGraphBuilder::BuildCopySeqStringChars(HValue* src, |
1824 HValue* src_offset, | 1830 HValue* src_offset, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 // Allocate the string object. HAllocate does not care whether we pass | 1959 // Allocate the string object. HAllocate does not care whether we pass |
1954 // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here. | 1960 // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here. |
1955 HAllocate* result = BuildAllocate( | 1961 HAllocate* result = BuildAllocate( |
1956 size, HType::String(), STRING_TYPE, allocation_mode); | 1962 size, HType::String(), STRING_TYPE, allocation_mode); |
1957 | 1963 |
1958 // We can safely skip the write barrier for storing map here. | 1964 // We can safely skip the write barrier for storing map here. |
1959 AddStoreMapNoWriteBarrier(result, map); | 1965 AddStoreMapNoWriteBarrier(result, map); |
1960 | 1966 |
1961 // Initialize the string fields. | 1967 // Initialize the string fields. |
1962 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), | 1968 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), |
1963 Add<HConstant>(String::kEmptyHashField)); | 1969 Add<HConstant>(String::kEmptyHashField), |
1964 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length); | 1970 INITIALIZING_STORE); |
| 1971 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length, |
| 1972 INITIALIZING_STORE); |
1965 | 1973 |
1966 // Copy characters to the result string. | 1974 // Copy characters to the result string. |
1967 IfBuilder if_twobyte(this); | 1975 IfBuilder if_twobyte(this); |
1968 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); | 1976 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); |
1969 if_twobyte.Then(); | 1977 if_twobyte.Then(); |
1970 { | 1978 { |
1971 // Copy characters from the left string. | 1979 // Copy characters from the left string. |
1972 BuildCopySeqStringChars( | 1980 BuildCopySeqStringChars( |
1973 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, | 1981 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, |
1974 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, | 1982 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2251 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, | 2259 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, |
2252 ElementsKind kind, | 2260 ElementsKind kind, |
2253 HValue* capacity) { | 2261 HValue* capacity) { |
2254 Factory* factory = isolate()->factory(); | 2262 Factory* factory = isolate()->factory(); |
2255 Handle<Map> map = IsFastDoubleElementsKind(kind) | 2263 Handle<Map> map = IsFastDoubleElementsKind(kind) |
2256 ? factory->fixed_double_array_map() | 2264 ? factory->fixed_double_array_map() |
2257 : factory->fixed_array_map(); | 2265 : factory->fixed_array_map(); |
2258 | 2266 |
2259 AddStoreMapConstant(elements, map); | 2267 AddStoreMapConstant(elements, map); |
2260 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), | 2268 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), |
2261 capacity); | 2269 capacity, INITIALIZING_STORE); |
2262 } | 2270 } |
2263 | 2271 |
2264 | 2272 |
2265 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( | 2273 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( |
2266 ElementsKind kind, | 2274 ElementsKind kind, |
2267 HValue* capacity) { | 2275 HValue* capacity) { |
2268 // The HForceRepresentation is to prevent possible deopt on int-smi | 2276 // The HForceRepresentation is to prevent possible deopt on int-smi |
2269 // conversion after allocation but before the new object fields are set. | 2277 // conversion after allocation but before the new object fields are set. |
2270 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); | 2278 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); |
2271 HValue* new_elements = BuildAllocateElements(kind, capacity); | 2279 HValue* new_elements = BuildAllocateElements(kind, capacity); |
2272 BuildInitializeElementsHeader(new_elements, kind, capacity); | 2280 BuildInitializeElementsHeader(new_elements, kind, capacity); |
2273 return new_elements; | 2281 return new_elements; |
2274 } | 2282 } |
2275 | 2283 |
2276 | 2284 |
2277 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, | 2285 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, |
2278 HValue* array_map, | 2286 HValue* array_map, |
2279 AllocationSiteMode mode, | 2287 AllocationSiteMode mode, |
2280 ElementsKind elements_kind, | 2288 ElementsKind elements_kind, |
2281 HValue* allocation_site_payload, | 2289 HValue* allocation_site_payload, |
2282 HValue* length_field) { | 2290 HValue* length_field) { |
2283 | 2291 |
2284 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map); | 2292 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map, |
| 2293 INITIALIZING_STORE); |
2285 | 2294 |
2286 HConstant* empty_fixed_array = | 2295 HConstant* empty_fixed_array = |
2287 Add<HConstant>(isolate()->factory()->empty_fixed_array()); | 2296 Add<HConstant>(isolate()->factory()->empty_fixed_array()); |
2288 | 2297 |
2289 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 2298 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
2290 Add<HStoreNamedField>(array, access, empty_fixed_array); | 2299 Add<HStoreNamedField>(array, access, empty_fixed_array, INITIALIZING_STORE); |
2291 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), | 2300 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), |
2292 length_field); | 2301 length_field, INITIALIZING_STORE); |
2293 | 2302 |
2294 if (mode == TRACK_ALLOCATION_SITE) { | 2303 if (mode == TRACK_ALLOCATION_SITE) { |
2295 BuildCreateAllocationMemento( | 2304 BuildCreateAllocationMemento( |
2296 array, Add<HConstant>(JSArray::kSize), allocation_site_payload); | 2305 array, Add<HConstant>(JSArray::kSize), allocation_site_payload); |
2297 } | 2306 } |
2298 | 2307 |
2299 int elements_location = JSArray::kSize; | 2308 int elements_location = JSArray::kSize; |
2300 if (mode == TRACK_ALLOCATION_SITE) { | 2309 if (mode == TRACK_ALLOCATION_SITE) { |
2301 elements_location += AllocationMemento::kSize; | 2310 elements_location += AllocationMemento::kSize; |
2302 } | 2311 } |
2303 | 2312 |
2304 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>( | 2313 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>( |
2305 array, Add<HConstant>(elements_location)); | 2314 array, Add<HConstant>(elements_location)); |
2306 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements); | 2315 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements, |
| 2316 INITIALIZING_STORE); |
2307 return elements; | 2317 return elements; |
2308 } | 2318 } |
2309 | 2319 |
2310 | 2320 |
2311 HInstruction* HGraphBuilder::AddElementAccess( | 2321 HInstruction* HGraphBuilder::AddElementAccess( |
2312 HValue* elements, | 2322 HValue* elements, |
2313 HValue* checked_key, | 2323 HValue* checked_key, |
2314 HValue* val, | 2324 HValue* val, |
2315 HValue* dependency, | 2325 HValue* dependency, |
2316 ElementsKind elements_kind, | 2326 ElementsKind elements_kind, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 BuildNewSpaceArrayCheck(new_capacity, new_kind); | 2397 BuildNewSpaceArrayCheck(new_capacity, new_kind); |
2388 | 2398 |
2389 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( | 2399 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( |
2390 new_kind, new_capacity); | 2400 new_kind, new_capacity); |
2391 | 2401 |
2392 BuildCopyElements(elements, kind, | 2402 BuildCopyElements(elements, kind, |
2393 new_elements, new_kind, | 2403 new_elements, new_kind, |
2394 length, new_capacity); | 2404 length, new_capacity); |
2395 | 2405 |
2396 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 2406 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
2397 new_elements); | 2407 new_elements, INITIALIZING_STORE); |
2398 | 2408 |
2399 return new_elements; | 2409 return new_elements; |
2400 } | 2410 } |
2401 | 2411 |
2402 | 2412 |
2403 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, | 2413 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, |
2404 ElementsKind elements_kind, | 2414 ElementsKind elements_kind, |
2405 HValue* from, | 2415 HValue* from, |
2406 HValue* to) { | 2416 HValue* to) { |
2407 // Fast elements kinds need to be initialized in case statements below cause | 2417 // Fast elements kinds need to be initialized in case statements below cause |
(...skipping 20 matching lines...) Expand all Loading... |
2428 | 2438 |
2429 // Since we're about to store a hole value, the store instruction below must | 2439 // Since we're about to store a hole value, the store instruction below must |
2430 // assume an elements kind that supports heap object values. | 2440 // assume an elements kind that supports heap object values. |
2431 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 2441 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
2432 elements_kind = FAST_HOLEY_ELEMENTS; | 2442 elements_kind = FAST_HOLEY_ELEMENTS; |
2433 } | 2443 } |
2434 | 2444 |
2435 if (initial_capacity >= 0) { | 2445 if (initial_capacity >= 0) { |
2436 for (int i = 0; i < initial_capacity; i++) { | 2446 for (int i = 0; i < initial_capacity; i++) { |
2437 HInstruction* key = Add<HConstant>(i); | 2447 HInstruction* key = Add<HConstant>(i); |
2438 Add<HStoreKeyed>(elements, key, hole, elements_kind); | 2448 Add<HStoreKeyed>(elements, key, hole, elements_kind, |
| 2449 PREINITIALIZING_STORE); |
2439 } | 2450 } |
2440 } else { | 2451 } else { |
2441 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); | 2452 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); |
2442 | 2453 |
2443 HValue* key = builder.BeginBody(from, to, Token::LT); | 2454 HValue* key = builder.BeginBody(from, to, Token::LT); |
2444 | 2455 |
2445 Add<HStoreKeyed>(elements, key, hole, elements_kind); | 2456 Add<HStoreKeyed>(elements, key, hole, elements_kind, PREINITIALIZING_STORE); |
2446 | 2457 |
2447 builder.EndBody(); | 2458 builder.EndBody(); |
2448 } | 2459 } |
2449 } | 2460 } |
2450 | 2461 |
2451 | 2462 |
2452 void HGraphBuilder::BuildCopyElements(HValue* from_elements, | 2463 void HGraphBuilder::BuildCopyElements(HValue* from_elements, |
2453 ElementsKind from_elements_kind, | 2464 ElementsKind from_elements_kind, |
2454 HValue* to_elements, | 2465 HValue* to_elements, |
2455 ElementsKind to_elements_kind, | 2466 ElementsKind to_elements_kind, |
(...skipping 25 matching lines...) Expand all Loading... |
2481 ? FAST_HOLEY_ELEMENTS : to_elements_kind; | 2492 ? FAST_HOLEY_ELEMENTS : to_elements_kind; |
2482 | 2493 |
2483 if (IsHoleyElementsKind(from_elements_kind) && | 2494 if (IsHoleyElementsKind(from_elements_kind) && |
2484 from_elements_kind != to_elements_kind) { | 2495 from_elements_kind != to_elements_kind) { |
2485 IfBuilder if_hole(this); | 2496 IfBuilder if_hole(this); |
2486 if_hole.If<HCompareHoleAndBranch>(element); | 2497 if_hole.If<HCompareHoleAndBranch>(element); |
2487 if_hole.Then(); | 2498 if_hole.Then(); |
2488 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind) | 2499 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind) |
2489 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double()) | 2500 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double()) |
2490 : graph()->GetConstantHole(); | 2501 : graph()->GetConstantHole(); |
2491 Add<HStoreKeyed>(to_elements, key, hole_constant, kind); | 2502 Add<HStoreKeyed>(to_elements, key, hole_constant, kind, |
| 2503 PREINITIALIZING_STORE); |
2492 if_hole.Else(); | 2504 if_hole.Else(); |
2493 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); | 2505 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind, |
| 2506 INITIALIZING_STORE); |
2494 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 2507 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
2495 if_hole.End(); | 2508 if_hole.End(); |
2496 } else { | 2509 } else { |
2497 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); | 2510 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind, |
| 2511 INITIALIZING_STORE); |
2498 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 2512 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
2499 } | 2513 } |
2500 | 2514 |
2501 builder.EndBody(); | 2515 builder.EndBody(); |
2502 | 2516 |
2503 if (!pre_fill_with_holes && length != capacity) { | 2517 if (!pre_fill_with_holes && length != capacity) { |
2504 // Fill unused capacity with the hole. | 2518 // Fill unused capacity with the hole. |
2505 BuildFillElementsWithHole(to_elements, to_elements_kind, | 2519 BuildFillElementsWithHole(to_elements, to_elements_kind, |
2506 key, capacity); | 2520 key, capacity); |
2507 } | 2521 } |
(...skipping 17 matching lines...) Expand all Loading... |
2525 HInstruction* object = Add<HAllocate>(size_in_bytes, | 2539 HInstruction* object = Add<HAllocate>(size_in_bytes, |
2526 HType::JSObject(), | 2540 HType::JSObject(), |
2527 NOT_TENURED, | 2541 NOT_TENURED, |
2528 JS_OBJECT_TYPE); | 2542 JS_OBJECT_TYPE); |
2529 | 2543 |
2530 // Copy the JS array part. | 2544 // Copy the JS array part. |
2531 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 2545 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
2532 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 2546 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
2533 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); | 2547 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
2534 Add<HStoreNamedField>(object, access, | 2548 Add<HStoreNamedField>(object, access, |
2535 Add<HLoadNamedField>(boilerplate, access)); | 2549 Add<HLoadNamedField>(boilerplate, access), |
| 2550 INITIALIZING_STORE); |
2536 } | 2551 } |
2537 } | 2552 } |
2538 | 2553 |
2539 // Create an allocation site info if requested. | 2554 // Create an allocation site info if requested. |
2540 if (mode == TRACK_ALLOCATION_SITE) { | 2555 if (mode == TRACK_ALLOCATION_SITE) { |
2541 BuildCreateAllocationMemento( | 2556 BuildCreateAllocationMemento( |
2542 object, Add<HConstant>(JSArray::kSize), allocation_site); | 2557 object, Add<HConstant>(JSArray::kSize), allocation_site); |
2543 } | 2558 } |
2544 | 2559 |
2545 if (length > 0) { | 2560 if (length > 0) { |
2546 HValue* boilerplate_elements = AddLoadElements(boilerplate); | 2561 HValue* boilerplate_elements = AddLoadElements(boilerplate); |
2547 HValue* object_elements; | 2562 HValue* object_elements; |
2548 if (IsFastDoubleElementsKind(kind)) { | 2563 if (IsFastDoubleElementsKind(kind)) { |
2549 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); | 2564 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); |
2550 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | 2565 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), |
2551 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); | 2566 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); |
2552 } else { | 2567 } else { |
2553 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); | 2568 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); |
2554 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | 2569 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), |
2555 NOT_TENURED, FIXED_ARRAY_TYPE); | 2570 NOT_TENURED, FIXED_ARRAY_TYPE); |
2556 } | 2571 } |
2557 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 2572 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
2558 object_elements); | 2573 object_elements, INITIALIZING_STORE); |
2559 | 2574 |
2560 // Copy the elements array header. | 2575 // Copy the elements array header. |
2561 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { | 2576 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { |
2562 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); | 2577 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); |
2563 Add<HStoreNamedField>(object_elements, access, | 2578 Add<HStoreNamedField>(object_elements, access, |
2564 Add<HLoadNamedField>(boilerplate_elements, access)); | 2579 Add<HLoadNamedField>(boilerplate_elements, access), |
| 2580 INITIALIZING_STORE); |
2565 } | 2581 } |
2566 | 2582 |
2567 // Copy the elements array contents. | 2583 // Copy the elements array contents. |
2568 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold | 2584 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold |
2569 // copying loops with constant length up to a given boundary and use this | 2585 // copying loops with constant length up to a given boundary and use this |
2570 // helper here instead. | 2586 // helper here instead. |
2571 for (int i = 0; i < length; i++) { | 2587 for (int i = 0; i < length; i++) { |
2572 HValue* key_constant = Add<HConstant>(i); | 2588 HValue* key_constant = Add<HConstant>(i); |
2573 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, | 2589 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, |
2574 static_cast<HValue*>(NULL), kind); | 2590 static_cast<HValue*>(NULL), kind); |
2575 Add<HStoreKeyed>(object_elements, key_constant, value, kind); | 2591 Add<HStoreKeyed>(object_elements, key_constant, value, kind, |
| 2592 INITIALIZING_STORE); |
2576 } | 2593 } |
2577 } | 2594 } |
2578 | 2595 |
2579 return object; | 2596 return object; |
2580 } | 2597 } |
2581 | 2598 |
2582 | 2599 |
2583 void HGraphBuilder::BuildCompareNil( | 2600 void HGraphBuilder::BuildCompareNil( |
2584 HValue* value, | 2601 HValue* value, |
2585 Type* type, | 2602 Type* type, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 void HGraphBuilder::BuildCreateAllocationMemento( | 2652 void HGraphBuilder::BuildCreateAllocationMemento( |
2636 HValue* previous_object, | 2653 HValue* previous_object, |
2637 HValue* previous_object_size, | 2654 HValue* previous_object_size, |
2638 HValue* allocation_site) { | 2655 HValue* allocation_site) { |
2639 ASSERT(allocation_site != NULL); | 2656 ASSERT(allocation_site != NULL); |
2640 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( | 2657 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( |
2641 previous_object, previous_object_size); | 2658 previous_object, previous_object_size); |
2642 AddStoreMapConstant( | 2659 AddStoreMapConstant( |
2643 allocation_memento, isolate()->factory()->allocation_memento_map()); | 2660 allocation_memento, isolate()->factory()->allocation_memento_map()); |
2644 Add<HStoreNamedField>( | 2661 Add<HStoreNamedField>( |
2645 allocation_memento, | 2662 allocation_memento, HObjectAccess::ForAllocationMementoSite(), |
2646 HObjectAccess::ForAllocationMementoSite(), | 2663 allocation_site, INITIALIZING_STORE); |
2647 allocation_site); | |
2648 if (FLAG_allocation_site_pretenuring) { | 2664 if (FLAG_allocation_site_pretenuring) { |
2649 HValue* memento_create_count = Add<HLoadNamedField>( | 2665 HValue* memento_create_count = Add<HLoadNamedField>( |
2650 allocation_site, HObjectAccess::ForAllocationSiteOffset( | 2666 allocation_site, HObjectAccess::ForAllocationSiteOffset( |
2651 AllocationSite::kPretenureCreateCountOffset)); | 2667 AllocationSite::kPretenureCreateCountOffset)); |
2652 memento_create_count = AddUncasted<HAdd>( | 2668 memento_create_count = AddUncasted<HAdd>( |
2653 memento_create_count, graph()->GetConstant1()); | 2669 memento_create_count, graph()->GetConstant1()); |
2654 // This smi value is reset to zero after every gc, overflow isn't a problem | 2670 // This smi value is reset to zero after every gc, overflow isn't a problem |
2655 // since the counter is bounded by the new space size. | 2671 // since the counter is bounded by the new space size. |
2656 memento_create_count->ClearFlag(HValue::kCanOverflow); | 2672 memento_create_count->ClearFlag(HValue::kCanOverflow); |
2657 HStoreNamedField* store = Add<HStoreNamedField>( | 2673 HStoreNamedField* store = Add<HStoreNamedField>( |
2658 allocation_site, HObjectAccess::ForAllocationSiteOffset( | 2674 allocation_site, HObjectAccess::ForAllocationSiteOffset( |
2659 AllocationSite::kPretenureCreateCountOffset), memento_create_count); | 2675 AllocationSite::kPretenureCreateCountOffset), memento_create_count, |
| 2676 INITIALIZING_STORE); |
2660 // No write barrier needed to store a smi. | 2677 // No write barrier needed to store a smi. |
2661 store->SkipWriteBarrier(); | 2678 store->SkipWriteBarrier(); |
2662 } | 2679 } |
2663 } | 2680 } |
2664 | 2681 |
2665 | 2682 |
2666 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { | 2683 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { |
2667 // Get the global context, then the native context | 2684 // Get the global context, then the native context |
2668 HInstruction* context = | 2685 HInstruction* context = |
2669 Add<HLoadNamedField>(closure, HObjectAccess::ForFunctionContextPointer()); | 2686 Add<HLoadNamedField>(closure, HObjectAccess::ForFunctionContextPointer()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2864 graph()->GetConstant0(), capacity); | 2881 graph()->GetConstant0(), capacity); |
2865 } | 2882 } |
2866 | 2883 |
2867 return new_object; | 2884 return new_object; |
2868 } | 2885 } |
2869 | 2886 |
2870 | 2887 |
2871 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, | 2888 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, |
2872 Handle<Map> map) { | 2889 Handle<Map> map) { |
2873 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), | 2890 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), |
2874 Add<HConstant>(map)); | 2891 Add<HConstant>(map), INITIALIZING_STORE); |
2875 } | 2892 } |
2876 | 2893 |
2877 | 2894 |
2878 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { | 2895 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { |
2879 HGlobalObject* global_object = Add<HGlobalObject>(); | 2896 HGlobalObject* global_object = Add<HGlobalObject>(); |
2880 HObjectAccess access = HObjectAccess::ForJSObjectOffset( | 2897 HObjectAccess access = HObjectAccess::ForJSObjectOffset( |
2881 GlobalObject::kBuiltinsOffset); | 2898 GlobalObject::kBuiltinsOffset); |
2882 HValue* builtins = Add<HLoadNamedField>(global_object, access); | 2899 HValue* builtins = Add<HLoadNamedField>(global_object, access); |
2883 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset( | 2900 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset( |
2884 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); | 2901 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); |
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5180 HValue* key = Add<HConstant>(i); | 5197 HValue* key = Add<HConstant>(i); |
5181 | 5198 |
5182 switch (boilerplate_elements_kind) { | 5199 switch (boilerplate_elements_kind) { |
5183 case FAST_SMI_ELEMENTS: | 5200 case FAST_SMI_ELEMENTS: |
5184 case FAST_HOLEY_SMI_ELEMENTS: | 5201 case FAST_HOLEY_SMI_ELEMENTS: |
5185 case FAST_ELEMENTS: | 5202 case FAST_ELEMENTS: |
5186 case FAST_HOLEY_ELEMENTS: | 5203 case FAST_HOLEY_ELEMENTS: |
5187 case FAST_DOUBLE_ELEMENTS: | 5204 case FAST_DOUBLE_ELEMENTS: |
5188 case FAST_HOLEY_DOUBLE_ELEMENTS: { | 5205 case FAST_HOLEY_DOUBLE_ELEMENTS: { |
5189 HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, | 5206 HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, |
5190 boilerplate_elements_kind); | 5207 boilerplate_elements_kind, |
| 5208 INITIALIZING_STORE); |
5191 instr->SetUninitialized(uninitialized); | 5209 instr->SetUninitialized(uninitialized); |
5192 break; | 5210 break; |
5193 } | 5211 } |
5194 default: | 5212 default: |
5195 UNREACHABLE(); | 5213 UNREACHABLE(); |
5196 break; | 5214 break; |
5197 } | 5215 } |
5198 | 5216 |
5199 Add<HSimulate>(expr->GetIdForElement(i)); | 5217 Add<HSimulate>(expr->GetIdForElement(i)); |
5200 } | 5218 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5256 field_access.WithRepresentation(Representation::Tagged()); | 5274 field_access.WithRepresentation(Representation::Tagged()); |
5257 if (transition_to_field) { | 5275 if (transition_to_field) { |
5258 // The store requires a mutable HeapNumber to be allocated. | 5276 // The store requires a mutable HeapNumber to be allocated. |
5259 NoObservableSideEffectsScope no_side_effects(this); | 5277 NoObservableSideEffectsScope no_side_effects(this); |
5260 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); | 5278 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); |
5261 HInstruction* heap_number = Add<HAllocate>(heap_number_size, | 5279 HInstruction* heap_number = Add<HAllocate>(heap_number_size, |
5262 HType::HeapNumber(), isolate()->heap()->GetPretenureMode(), | 5280 HType::HeapNumber(), isolate()->heap()->GetPretenureMode(), |
5263 HEAP_NUMBER_TYPE); | 5281 HEAP_NUMBER_TYPE); |
5264 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map()); | 5282 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map()); |
5265 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), | 5283 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), |
5266 value); | 5284 value, INITIALIZING_STORE); |
5267 instr = New<HStoreNamedField>(checked_object->ActualValue(), | 5285 instr = New<HStoreNamedField>(checked_object->ActualValue(), |
5268 heap_number_access, | 5286 heap_number_access, |
5269 heap_number); | 5287 heap_number, INITIALIZING_STORE); |
5270 } else { | 5288 } else { |
5271 // Already holds a HeapNumber; load the box and write its value field. | 5289 // Already holds a HeapNumber; load the box and write its value field. |
5272 HInstruction* heap_number = Add<HLoadNamedField>(checked_object, | 5290 HInstruction* heap_number = Add<HLoadNamedField>(checked_object, |
5273 heap_number_access); | 5291 heap_number_access); |
5274 heap_number->set_type(HType::HeapNumber()); | 5292 heap_number->set_type(HType::HeapNumber()); |
5275 instr = New<HStoreNamedField>(heap_number, | 5293 instr = New<HStoreNamedField>(heap_number, |
5276 HObjectAccess::ForHeapNumberValue(), | 5294 HObjectAccess::ForHeapNumberValue(), |
5277 value); | 5295 value, STORE_TO_INITIALIZED_ENTRY); |
5278 } | 5296 } |
5279 } else { | 5297 } else { |
5280 // This is a normal store. | 5298 // This is a normal store. |
5281 instr = New<HStoreNamedField>( | 5299 instr = New<HStoreNamedField>( |
5282 checked_object->ActualValue(), field_access, value, | 5300 checked_object->ActualValue(), field_access, value, |
5283 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); | 5301 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); |
5284 } | 5302 } |
5285 | 5303 |
5286 if (transition_to_field) { | 5304 if (transition_to_field) { |
5287 Handle<Map> transition(lookup->GetTransitionMapFromMap(*map)); | 5305 Handle<Map> transition(lookup->GetTransitionMapFromMap(*map)); |
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7647 ? Add<HConstant>(factory->the_hole_value()) | 7665 ? Add<HConstant>(factory->the_hole_value()) |
7648 : Add<HConstant>(nan_double); | 7666 : Add<HConstant>(nan_double); |
7649 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 7667 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
7650 elements_kind = FAST_HOLEY_ELEMENTS; | 7668 elements_kind = FAST_HOLEY_ELEMENTS; |
7651 } | 7669 } |
7652 AddElementAccess( | 7670 AddElementAccess( |
7653 elements, reduced_length, hole, bounds_check, elements_kind, true); | 7671 elements, reduced_length, hole, bounds_check, elements_kind, true); |
7654 } | 7672 } |
7655 Add<HStoreNamedField>( | 7673 Add<HStoreNamedField>( |
7656 checked_object, HObjectAccess::ForArrayLength(elements_kind), | 7674 checked_object, HObjectAccess::ForArrayLength(elements_kind), |
7657 reduced_length); | 7675 reduced_length, STORE_TO_INITIALIZED_ENTRY); |
7658 if (!ast_context()->IsEffect()) Push(result); | 7676 if (!ast_context()->IsEffect()) Push(result); |
7659 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); | 7677 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); |
7660 if (!ast_context()->IsEffect()) Drop(1); | 7678 if (!ast_context()->IsEffect()) Drop(1); |
7661 ast_context()->ReturnValue(result); | 7679 ast_context()->ReturnValue(result); |
7662 return true; | 7680 return true; |
7663 } | 7681 } |
7664 case kArrayPush: { | 7682 case kArrayPush: { |
7665 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { | 7683 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { |
7666 return false; | 7684 return false; |
7667 } | 7685 } |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8068 // TODO(mvstanton): If all the arguments are constants in smi range, then | 8086 // TODO(mvstanton): If all the arguments are constants in smi range, then |
8069 // we could set fill_with_hole to false and save a few instructions. | 8087 // we could set fill_with_hole to false and save a few instructions. |
8070 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind) | 8088 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind) |
8071 ? JSArrayBuilder::FILL_WITH_HOLE | 8089 ? JSArrayBuilder::FILL_WITH_HOLE |
8072 : JSArrayBuilder::DONT_FILL_WITH_HOLE; | 8090 : JSArrayBuilder::DONT_FILL_WITH_HOLE; |
8073 new_object = array_builder.AllocateArray(length, length, fill_mode); | 8091 new_object = array_builder.AllocateArray(length, length, fill_mode); |
8074 HValue* elements = array_builder.GetElementsLocation(); | 8092 HValue* elements = array_builder.GetElementsLocation(); |
8075 for (int i = 0; i < argument_count; i++) { | 8093 for (int i = 0; i < argument_count; i++) { |
8076 HValue* value = environment()->ExpressionStackAt(argument_count - i - 1); | 8094 HValue* value = environment()->ExpressionStackAt(argument_count - i - 1); |
8077 HValue* constant_i = Add<HConstant>(i); | 8095 HValue* constant_i = Add<HConstant>(i); |
8078 Add<HStoreKeyed>(elements, constant_i, value, kind); | 8096 Add<HStoreKeyed>(elements, constant_i, value, kind, INITIALIZING_STORE); |
8079 } | 8097 } |
8080 } | 8098 } |
8081 | 8099 |
8082 Drop(argument_count + 1); // drop constructor and args. | 8100 Drop(argument_count + 1); // drop constructor and args. |
8083 ast_context()->ReturnValue(new_object); | 8101 ast_context()->ReturnValue(new_object); |
8084 } | 8102 } |
8085 | 8103 |
8086 | 8104 |
8087 // Checks whether allocation using the given constructor can be inlined. | 8105 // Checks whether allocation using the given constructor can be inlined. |
8088 static bool IsAllocationInlineable(Handle<JSFunction> constructor) { | 8106 static bool IsAllocationInlineable(Handle<JSFunction> constructor) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8185 HValue* constructor_value = Add<HConstant>(constructor); | 8203 HValue* constructor_value = Add<HConstant>(constructor); |
8186 HValue* initial_map_value = | 8204 HValue* initial_map_value = |
8187 Add<HLoadNamedField>(constructor_value, HObjectAccess::ForJSObjectOffset( | 8205 Add<HLoadNamedField>(constructor_value, HObjectAccess::ForJSObjectOffset( |
8188 JSFunction::kPrototypeOrInitialMapOffset)); | 8206 JSFunction::kPrototypeOrInitialMapOffset)); |
8189 | 8207 |
8190 // Initialize map and fields of the newly allocated object. | 8208 // Initialize map and fields of the newly allocated object. |
8191 { NoObservableSideEffectsScope no_effects(this); | 8209 { NoObservableSideEffectsScope no_effects(this); |
8192 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); | 8210 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); |
8193 Add<HStoreNamedField>(receiver, | 8211 Add<HStoreNamedField>(receiver, |
8194 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), | 8212 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), |
8195 initial_map_value); | 8213 initial_map_value, INITIALIZING_STORE); |
8196 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); | 8214 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); |
8197 Add<HStoreNamedField>(receiver, | 8215 Add<HStoreNamedField>(receiver, |
8198 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), | 8216 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), |
8199 empty_fixed_array); | 8217 empty_fixed_array, INITIALIZING_STORE); |
8200 Add<HStoreNamedField>(receiver, | 8218 Add<HStoreNamedField>(receiver, |
8201 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), | 8219 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), |
8202 empty_fixed_array); | 8220 empty_fixed_array, INITIALIZING_STORE); |
8203 if (initial_map->inobject_properties() != 0) { | 8221 if (initial_map->inobject_properties() != 0) { |
8204 HConstant* undefined = graph()->GetConstantUndefined(); | 8222 HConstant* undefined = graph()->GetConstantUndefined(); |
8205 for (int i = 0; i < initial_map->inobject_properties(); i++) { | 8223 for (int i = 0; i < initial_map->inobject_properties(); i++) { |
8206 int property_offset = JSObject::kHeaderSize + i * kPointerSize; | 8224 int property_offset = JSObject::kHeaderSize + i * kPointerSize; |
8207 Add<HStoreNamedField>(receiver, | 8225 Add<HStoreNamedField>(receiver, |
8208 HObjectAccess::ForJSObjectOffset(property_offset), | 8226 HObjectAccess::ForJSObjectOffset(property_offset), |
8209 undefined); | 8227 undefined, PREINITIALIZING_STORE); |
8210 } | 8228 } |
8211 } | 8229 } |
8212 } | 8230 } |
8213 | 8231 |
8214 // Replace the constructor function with a newly allocated receiver using | 8232 // Replace the constructor function with a newly allocated receiver using |
8215 // the index of the receiver from the top of the expression stack. | 8233 // the index of the receiver from the top of the expression stack. |
8216 const int receiver_index = argument_count - 1; | 8234 const int receiver_index = argument_count - 1; |
8217 ASSERT(environment()->ExpressionStackAt(receiver_index) == function); | 8235 ASSERT(environment()->ExpressionStackAt(receiver_index) == function); |
8218 environment()->SetExpressionStackAt(receiver_index, receiver); | 8236 environment()->SetExpressionStackAt(receiver_index, receiver); |
8219 | 8237 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8284 HValue* obj, | 8302 HValue* obj, |
8285 HValue* buffer, | 8303 HValue* buffer, |
8286 HValue* byte_offset, | 8304 HValue* byte_offset, |
8287 HValue* byte_length) { | 8305 HValue* byte_length) { |
8288 | 8306 |
8289 for (int offset = ViewClass::kSize; | 8307 for (int offset = ViewClass::kSize; |
8290 offset < ViewClass::kSizeWithInternalFields; | 8308 offset < ViewClass::kSizeWithInternalFields; |
8291 offset += kPointerSize) { | 8309 offset += kPointerSize) { |
8292 Add<HStoreNamedField>(obj, | 8310 Add<HStoreNamedField>(obj, |
8293 HObjectAccess::ForJSObjectOffset(offset), | 8311 HObjectAccess::ForJSObjectOffset(offset), |
8294 Add<HConstant>(static_cast<int32_t>(0))); | 8312 graph()->GetConstant0(), INITIALIZING_STORE); |
8295 } | 8313 } |
8296 | 8314 |
8297 Add<HStoreNamedField>( | 8315 Add<HStoreNamedField>( |
8298 obj, | 8316 obj, |
8299 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); | 8317 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer, INITIALIZING_STORE); |
8300 Add<HStoreNamedField>( | 8318 Add<HStoreNamedField>( |
8301 obj, | 8319 obj, |
8302 HObjectAccess::ForJSArrayBufferViewByteOffset(), | 8320 HObjectAccess::ForJSArrayBufferViewByteOffset(), |
8303 byte_offset); | 8321 byte_offset, INITIALIZING_STORE); |
8304 Add<HStoreNamedField>( | 8322 Add<HStoreNamedField>( |
8305 obj, | 8323 obj, |
8306 HObjectAccess::ForJSArrayBufferViewByteLength(), | 8324 HObjectAccess::ForJSArrayBufferViewByteLength(), |
8307 byte_length); | 8325 byte_length, INITIALIZING_STORE); |
8308 | 8326 |
8309 HObjectAccess weak_first_view_access = | 8327 HObjectAccess weak_first_view_access = |
8310 HObjectAccess::ForJSArrayBufferWeakFirstView(); | 8328 HObjectAccess::ForJSArrayBufferWeakFirstView(); |
8311 Add<HStoreNamedField>(obj, | 8329 Add<HStoreNamedField>(obj, |
8312 HObjectAccess::ForJSArrayBufferViewWeakNext(), | 8330 HObjectAccess::ForJSArrayBufferViewWeakNext(), |
8313 Add<HLoadNamedField>(buffer, weak_first_view_access)); | 8331 Add<HLoadNamedField>(buffer, weak_first_view_access), |
8314 Add<HStoreNamedField>(buffer, weak_first_view_access, obj); | 8332 INITIALIZING_STORE); |
| 8333 Add<HStoreNamedField>( |
| 8334 buffer, weak_first_view_access, obj, INITIALIZING_STORE); |
8315 } | 8335 } |
8316 | 8336 |
8317 | 8337 |
8318 void HOptimizedGraphBuilder::VisitDataViewInitialize( | 8338 void HOptimizedGraphBuilder::VisitDataViewInitialize( |
8319 CallRuntime* expr) { | 8339 CallRuntime* expr) { |
8320 ZoneList<Expression*>* arguments = expr->arguments(); | 8340 ZoneList<Expression*>* arguments = expr->arguments(); |
8321 | 8341 |
8322 NoObservableSideEffectsScope scope(this); | 8342 NoObservableSideEffectsScope scope(this); |
8323 ASSERT(arguments->length()== 4); | 8343 ASSERT(arguments->length()== 4); |
8324 CHECK_ALIVE(VisitForValue(arguments->at(0))); | 8344 CHECK_ALIVE(VisitForValue(arguments->at(0))); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8394 | 8414 |
8395 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 8415 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
8396 size_t element_size = 1; // Bogus initialization. | 8416 size_t element_size = 1; // Bogus initialization. |
8397 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size); | 8417 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size); |
8398 | 8418 |
8399 HInstruction* length = AddUncasted<HDiv>(byte_length, | 8419 HInstruction* length = AddUncasted<HDiv>(byte_length, |
8400 Add<HConstant>(static_cast<int32_t>(element_size))); | 8420 Add<HConstant>(static_cast<int32_t>(element_size))); |
8401 | 8421 |
8402 Add<HStoreNamedField>(obj, | 8422 Add<HStoreNamedField>(obj, |
8403 HObjectAccess::ForJSTypedArrayLength(), | 8423 HObjectAccess::ForJSTypedArrayLength(), |
8404 length); | 8424 length, INITIALIZING_STORE); |
8405 | 8425 |
8406 HValue* elements = | 8426 HValue* elements = |
8407 Add<HAllocate>( | 8427 Add<HAllocate>( |
8408 Add<HConstant>(ExternalArray::kAlignedSize), | 8428 Add<HConstant>(ExternalArray::kAlignedSize), |
8409 HType::JSArray(), | 8429 HType::JSArray(), |
8410 NOT_TENURED, | 8430 NOT_TENURED, |
8411 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type)); | 8431 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type)); |
8412 | 8432 |
8413 Handle<Map> external_array_map( | 8433 Handle<Map> external_array_map( |
8414 isolate()->heap()->MapForExternalArrayType(array_type)); | 8434 isolate()->heap()->MapForExternalArrayType(array_type)); |
8415 Add<HStoreNamedField>(elements, | 8435 AddStoreMapConstant(elements, external_array_map); |
8416 HObjectAccess::ForMap(), | |
8417 Add<HConstant>(external_array_map)); | |
8418 | 8436 |
8419 HValue* backing_store = Add<HLoadNamedField>( | 8437 HValue* backing_store = Add<HLoadNamedField>( |
8420 buffer, HObjectAccess::ForJSArrayBufferBackingStore()); | 8438 buffer, HObjectAccess::ForJSArrayBufferBackingStore()); |
8421 | 8439 |
8422 HValue* typed_array_start; | 8440 HValue* typed_array_start; |
8423 if (is_zero_byte_offset) { | 8441 if (is_zero_byte_offset) { |
8424 typed_array_start = backing_store; | 8442 typed_array_start = backing_store; |
8425 } else { | 8443 } else { |
8426 HInstruction* external_pointer = | 8444 HInstruction* external_pointer = |
8427 AddUncasted<HAdd>(backing_store, byte_offset); | 8445 AddUncasted<HAdd>(backing_store, byte_offset); |
8428 // Arguments are checked prior to call to TypedArrayInitialize, | 8446 // Arguments are checked prior to call to TypedArrayInitialize, |
8429 // including byte_offset. | 8447 // including byte_offset. |
8430 external_pointer->ClearFlag(HValue::kCanOverflow); | 8448 external_pointer->ClearFlag(HValue::kCanOverflow); |
8431 typed_array_start = external_pointer; | 8449 typed_array_start = external_pointer; |
8432 } | 8450 } |
8433 | 8451 |
8434 Add<HStoreNamedField>(elements, | |
8435 HObjectAccess::ForExternalArrayExternalPointer(), | |
8436 typed_array_start); | |
8437 Add<HStoreNamedField>(elements, | |
8438 HObjectAccess::ForFixedArrayLength(), | |
8439 length); | |
8440 Add<HStoreNamedField>( | 8452 Add<HStoreNamedField>( |
8441 obj, HObjectAccess::ForElementsPointer(), elements); | 8453 elements, HObjectAccess::ForExternalArrayExternalPointer(), |
| 8454 typed_array_start, INITIALIZING_STORE); |
| 8455 Add<HStoreNamedField>( |
| 8456 elements, HObjectAccess::ForFixedArrayLength(), length, |
| 8457 INITIALIZING_STORE); |
| 8458 Add<HStoreNamedField>( |
| 8459 obj, HObjectAccess::ForElementsPointer(), elements, INITIALIZING_STORE); |
8442 } | 8460 } |
8443 | 8461 |
8444 if (!is_zero_byte_offset) { | 8462 if (!is_zero_byte_offset) { |
8445 byte_offset_smi.Else(); | 8463 byte_offset_smi.Else(); |
8446 { // byte_offset is not Smi. | 8464 { // byte_offset is not Smi. |
8447 Push(Add<HPushArgument>(obj)); | 8465 Push(Add<HPushArgument>(obj)); |
8448 VisitArgument(arguments->at(kArrayIdArg)); | 8466 VisitArgument(arguments->at(kArrayIdArg)); |
8449 Push(Add<HPushArgument>(buffer)); | 8467 Push(Add<HPushArgument>(buffer)); |
8450 Push(Add<HPushArgument>(byte_offset)); | 8468 Push(Add<HPushArgument>(byte_offset)); |
8451 Push(Add<HPushArgument>(byte_length)); | 8469 Push(Add<HPushArgument>(byte_length)); |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9668 ASSERT(boilerplate_object->properties()->length() == 0); | 9686 ASSERT(boilerplate_object->properties()->length() == 0); |
9669 | 9687 |
9670 Handle<Map> boilerplate_object_map(boilerplate_object->map()); | 9688 Handle<Map> boilerplate_object_map(boilerplate_object->map()); |
9671 AddStoreMapConstant(object, boilerplate_object_map); | 9689 AddStoreMapConstant(object, boilerplate_object_map); |
9672 | 9690 |
9673 Handle<Object> properties_field = | 9691 Handle<Object> properties_field = |
9674 Handle<Object>(boilerplate_object->properties(), isolate()); | 9692 Handle<Object>(boilerplate_object->properties(), isolate()); |
9675 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); | 9693 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); |
9676 HInstruction* properties = Add<HConstant>(properties_field); | 9694 HInstruction* properties = Add<HConstant>(properties_field); |
9677 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 9695 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
9678 Add<HStoreNamedField>(object, access, properties); | 9696 Add<HStoreNamedField>(object, access, properties, INITIALIZING_STORE); |
9679 | 9697 |
9680 if (boilerplate_object->IsJSArray()) { | 9698 if (boilerplate_object->IsJSArray()) { |
9681 Handle<JSArray> boilerplate_array = | 9699 Handle<JSArray> boilerplate_array = |
9682 Handle<JSArray>::cast(boilerplate_object); | 9700 Handle<JSArray>::cast(boilerplate_object); |
9683 Handle<Object> length_field = | 9701 Handle<Object> length_field = |
9684 Handle<Object>(boilerplate_array->length(), isolate()); | 9702 Handle<Object>(boilerplate_array->length(), isolate()); |
9685 HInstruction* length = Add<HConstant>(length_field); | 9703 HInstruction* length = Add<HConstant>(length_field); |
9686 | 9704 |
9687 ASSERT(boilerplate_array->length()->IsSmi()); | 9705 ASSERT(boilerplate_array->length()->IsSmi()); |
9688 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( | 9706 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( |
9689 boilerplate_array->GetElementsKind()), length); | 9707 boilerplate_array->GetElementsKind()), length, INITIALIZING_STORE); |
9690 } | 9708 } |
9691 } | 9709 } |
9692 | 9710 |
9693 | 9711 |
9694 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( | 9712 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( |
9695 Handle<JSObject> boilerplate_object, | 9713 Handle<JSObject> boilerplate_object, |
9696 HInstruction* object, | 9714 HInstruction* object, |
9697 HInstruction* object_elements) { | 9715 HInstruction* object_elements) { |
9698 ASSERT(boilerplate_object->properties()->length() == 0); | 9716 ASSERT(boilerplate_object->properties()->length() == 0); |
9699 if (object_elements == NULL) { | 9717 if (object_elements == NULL) { |
9700 Handle<Object> elements_field = | 9718 Handle<Object> elements_field = |
9701 Handle<Object>(boilerplate_object->elements(), isolate()); | 9719 Handle<Object>(boilerplate_object->elements(), isolate()); |
9702 object_elements = Add<HConstant>(elements_field); | 9720 object_elements = Add<HConstant>(elements_field); |
9703 } | 9721 } |
9704 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 9722 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
9705 object_elements); | 9723 object_elements, INITIALIZING_STORE); |
9706 } | 9724 } |
9707 | 9725 |
9708 | 9726 |
9709 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( | 9727 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( |
9710 Handle<JSObject> boilerplate_object, | 9728 Handle<JSObject> boilerplate_object, |
9711 HInstruction* object, | 9729 HInstruction* object, |
9712 AllocationSiteUsageContext* site_context, | 9730 AllocationSiteUsageContext* site_context, |
9713 PretenureFlag pretenure_flag) { | 9731 PretenureFlag pretenure_flag) { |
9714 Handle<DescriptorArray> descriptors( | 9732 Handle<DescriptorArray> descriptors( |
9715 boilerplate_object->map()->instance_descriptors()); | 9733 boilerplate_object->map()->instance_descriptors()); |
(...skipping 15 matching lines...) Expand all Loading... |
9731 HObjectAccess access = boilerplate_object->IsJSArray() ? | 9749 HObjectAccess access = boilerplate_object->IsJSArray() ? |
9732 HObjectAccess::ForJSArrayOffset(property_offset) : | 9750 HObjectAccess::ForJSArrayOffset(property_offset) : |
9733 HObjectAccess::ForJSObjectOffset(property_offset); | 9751 HObjectAccess::ForJSObjectOffset(property_offset); |
9734 | 9752 |
9735 if (value->IsJSObject()) { | 9753 if (value->IsJSObject()) { |
9736 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9754 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
9737 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 9755 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
9738 HInstruction* result = | 9756 HInstruction* result = |
9739 BuildFastLiteral(value_object, site_context); | 9757 BuildFastLiteral(value_object, site_context); |
9740 site_context->ExitScope(current_site, value_object); | 9758 site_context->ExitScope(current_site, value_object); |
9741 Add<HStoreNamedField>(object, access, result); | 9759 Add<HStoreNamedField>(object, access, result, INITIALIZING_STORE); |
9742 } else { | 9760 } else { |
9743 Representation representation = details.representation(); | 9761 Representation representation = details.representation(); |
9744 HInstruction* value_instruction; | 9762 HInstruction* value_instruction; |
9745 | 9763 |
9746 if (representation.IsDouble()) { | 9764 if (representation.IsDouble()) { |
9747 // Allocate a HeapNumber box and store the value into it. | 9765 // Allocate a HeapNumber box and store the value into it. |
9748 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); | 9766 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); |
9749 // This heap number alloc does not have a corresponding | 9767 // This heap number alloc does not have a corresponding |
9750 // AllocationSite. That is okay because | 9768 // AllocationSite. That is okay because |
9751 // 1) it's a child object of another object with a valid allocation site | 9769 // 1) it's a child object of another object with a valid allocation site |
9752 // 2) we can just use the mode of the parent object for pretenuring | 9770 // 2) we can just use the mode of the parent object for pretenuring |
9753 HInstruction* double_box = | 9771 HInstruction* double_box = |
9754 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), | 9772 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), |
9755 pretenure_flag, HEAP_NUMBER_TYPE); | 9773 pretenure_flag, HEAP_NUMBER_TYPE); |
9756 AddStoreMapConstant(double_box, | 9774 AddStoreMapConstant(double_box, |
9757 isolate()->factory()->heap_number_map()); | 9775 isolate()->factory()->heap_number_map()); |
9758 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), | 9776 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), |
9759 Add<HConstant>(value)); | 9777 Add<HConstant>(value), INITIALIZING_STORE); |
9760 value_instruction = double_box; | 9778 value_instruction = double_box; |
9761 } else if (representation.IsSmi() && value->IsUninitialized()) { | 9779 } else if (representation.IsSmi() && value->IsUninitialized()) { |
9762 value_instruction = graph()->GetConstant0(); | 9780 value_instruction = graph()->GetConstant0(); |
9763 } else { | 9781 } else { |
9764 value_instruction = Add<HConstant>(value); | 9782 value_instruction = Add<HConstant>(value); |
9765 } | 9783 } |
9766 | 9784 |
9767 Add<HStoreNamedField>(object, access, value_instruction); | 9785 Add<HStoreNamedField>(object, access, value_instruction, |
| 9786 INITIALIZING_STORE); |
9768 } | 9787 } |
9769 } | 9788 } |
9770 | 9789 |
9771 int inobject_properties = boilerplate_object->map()->inobject_properties(); | 9790 int inobject_properties = boilerplate_object->map()->inobject_properties(); |
9772 HInstruction* value_instruction = | 9791 HInstruction* value_instruction = |
9773 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); | 9792 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); |
9774 for (int i = copied_fields; i < inobject_properties; i++) { | 9793 for (int i = copied_fields; i < inobject_properties; i++) { |
9775 ASSERT(boilerplate_object->IsJSObject()); | 9794 ASSERT(boilerplate_object->IsJSObject()); |
9776 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); | 9795 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); |
9777 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); | 9796 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); |
9778 Add<HStoreNamedField>(object, access, value_instruction); | 9797 Add<HStoreNamedField>(object, access, value_instruction, |
| 9798 PREINITIALIZING_STORE); |
9779 } | 9799 } |
9780 } | 9800 } |
9781 | 9801 |
9782 | 9802 |
9783 void HOptimizedGraphBuilder::BuildEmitElements( | 9803 void HOptimizedGraphBuilder::BuildEmitElements( |
9784 Handle<JSObject> boilerplate_object, | 9804 Handle<JSObject> boilerplate_object, |
9785 Handle<FixedArrayBase> elements, | 9805 Handle<FixedArrayBase> elements, |
9786 HValue* object_elements, | 9806 HValue* object_elements, |
9787 AllocationSiteUsageContext* site_context) { | 9807 AllocationSiteUsageContext* site_context) { |
9788 ElementsKind kind = boilerplate_object->map()->elements_kind(); | 9808 ElementsKind kind = boilerplate_object->map()->elements_kind(); |
(...skipping 19 matching lines...) Expand all Loading... |
9808 HValue* object_elements) { | 9828 HValue* object_elements) { |
9809 HInstruction* boilerplate_elements = Add<HConstant>(elements); | 9829 HInstruction* boilerplate_elements = Add<HConstant>(elements); |
9810 int elements_length = elements->length(); | 9830 int elements_length = elements->length(); |
9811 for (int i = 0; i < elements_length; i++) { | 9831 for (int i = 0; i < elements_length; i++) { |
9812 HValue* key_constant = Add<HConstant>(i); | 9832 HValue* key_constant = Add<HConstant>(i); |
9813 HInstruction* value_instruction = | 9833 HInstruction* value_instruction = |
9814 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 9834 Add<HLoadKeyed>(boilerplate_elements, key_constant, |
9815 static_cast<HValue*>(NULL), kind, | 9835 static_cast<HValue*>(NULL), kind, |
9816 ALLOW_RETURN_HOLE); | 9836 ALLOW_RETURN_HOLE); |
9817 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, | 9837 HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, |
9818 value_instruction, kind); | 9838 value_instruction, kind, |
| 9839 INITIALIZING_STORE); |
9819 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 9840 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
9820 } | 9841 } |
9821 } | 9842 } |
9822 | 9843 |
9823 | 9844 |
9824 void HOptimizedGraphBuilder::BuildEmitFixedArray( | 9845 void HOptimizedGraphBuilder::BuildEmitFixedArray( |
9825 Handle<FixedArrayBase> elements, | 9846 Handle<FixedArrayBase> elements, |
9826 ElementsKind kind, | 9847 ElementsKind kind, |
9827 HValue* object_elements, | 9848 HValue* object_elements, |
9828 AllocationSiteUsageContext* site_context) { | 9849 AllocationSiteUsageContext* site_context) { |
9829 HInstruction* boilerplate_elements = Add<HConstant>(elements); | 9850 HInstruction* boilerplate_elements = Add<HConstant>(elements); |
9830 int elements_length = elements->length(); | 9851 int elements_length = elements->length(); |
9831 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); | 9852 Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); |
9832 for (int i = 0; i < elements_length; i++) { | 9853 for (int i = 0; i < elements_length; i++) { |
9833 Handle<Object> value(fast_elements->get(i), isolate()); | 9854 Handle<Object> value(fast_elements->get(i), isolate()); |
9834 HValue* key_constant = Add<HConstant>(i); | 9855 HValue* key_constant = Add<HConstant>(i); |
9835 if (value->IsJSObject()) { | 9856 if (value->IsJSObject()) { |
9836 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9857 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
9837 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 9858 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
9838 HInstruction* result = | 9859 HInstruction* result = |
9839 BuildFastLiteral(value_object, site_context); | 9860 BuildFastLiteral(value_object, site_context); |
9840 site_context->ExitScope(current_site, value_object); | 9861 site_context->ExitScope(current_site, value_object); |
9841 Add<HStoreKeyed>(object_elements, key_constant, result, kind); | 9862 Add<HStoreKeyed>(object_elements, key_constant, result, kind, |
| 9863 INITIALIZING_STORE); |
9842 } else { | 9864 } else { |
9843 HInstruction* value_instruction = | 9865 HInstruction* value_instruction = |
9844 Add<HLoadKeyed>(boilerplate_elements, key_constant, | 9866 Add<HLoadKeyed>(boilerplate_elements, key_constant, |
9845 static_cast<HValue*>(NULL), kind, | 9867 static_cast<HValue*>(NULL), kind, |
9846 ALLOW_RETURN_HOLE); | 9868 ALLOW_RETURN_HOLE); |
9847 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); | 9869 Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind, |
| 9870 INITIALIZING_STORE); |
9848 } | 9871 } |
9849 } | 9872 } |
9850 } | 9873 } |
9851 | 9874 |
9852 | 9875 |
9853 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 9876 void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
9854 ASSERT(!HasStackOverflow()); | 9877 ASSERT(!HasStackOverflow()); |
9855 ASSERT(current_block() != NULL); | 9878 ASSERT(current_block() != NULL); |
9856 ASSERT(current_block()->HasPredecessor()); | 9879 ASSERT(current_block()->HasPredecessor()); |
9857 HInstruction* instr = BuildThisFunction(); | 9880 HInstruction* instr = BuildThisFunction(); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10221 HBasicBlock* if_js_value = graph()->CreateBasicBlock(); | 10244 HBasicBlock* if_js_value = graph()->CreateBasicBlock(); |
10222 HBasicBlock* not_js_value = graph()->CreateBasicBlock(); | 10245 HBasicBlock* not_js_value = graph()->CreateBasicBlock(); |
10223 typecheck->SetSuccessorAt(0, if_js_value); | 10246 typecheck->SetSuccessorAt(0, if_js_value); |
10224 typecheck->SetSuccessorAt(1, not_js_value); | 10247 typecheck->SetSuccessorAt(1, not_js_value); |
10225 FinishCurrentBlock(typecheck); | 10248 FinishCurrentBlock(typecheck); |
10226 Goto(not_js_value, join); | 10249 Goto(not_js_value, join); |
10227 | 10250 |
10228 // Create in-object property store to kValueOffset. | 10251 // Create in-object property store to kValueOffset. |
10229 set_current_block(if_js_value); | 10252 set_current_block(if_js_value); |
10230 Add<HStoreNamedField>(object, | 10253 Add<HStoreNamedField>(object, |
10231 HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), value); | 10254 HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), value, |
| 10255 INITIALIZING_STORE); |
10232 Goto(if_js_value, join); | 10256 Goto(if_js_value, join); |
10233 join->SetJoinId(call->id()); | 10257 join->SetJoinId(call->id()); |
10234 set_current_block(join); | 10258 set_current_block(join); |
10235 return ast_context()->ReturnValue(value); | 10259 return ast_context()->ReturnValue(value); |
10236 } | 10260 } |
10237 | 10261 |
10238 | 10262 |
10239 // Fast support for charCodeAt(n). | 10263 // Fast support for charCodeAt(n). |
10240 void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { | 10264 void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { |
10241 ASSERT(call->arguments()->length() == 2); | 10265 ASSERT(call->arguments()->length() == 2); |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11083 if (ShouldProduceTraceOutput()) { | 11107 if (ShouldProduceTraceOutput()) { |
11084 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11108 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11085 } | 11109 } |
11086 | 11110 |
11087 #ifdef DEBUG | 11111 #ifdef DEBUG |
11088 graph_->Verify(false); // No full verify. | 11112 graph_->Verify(false); // No full verify. |
11089 #endif | 11113 #endif |
11090 } | 11114 } |
11091 | 11115 |
11092 } } // namespace v8::internal | 11116 } } // namespace v8::internal |
OLD | NEW |