Chromium Code Reviews| 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); |
|
Igor Sheludko
2014/01/27 15:14:16
The counter should have been already initialized.
| |
| 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 } | 1348 } |
| 1349 | 1349 |
| 1350 length_checker.Else(); | 1350 length_checker.Else(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1414 HInstruction* array_length = is_jsarray | 1414 HInstruction* array_length = is_jsarray |
| 1415 ? Add<HLoadNamedField>(object, HObjectAccess::ForArrayLength(from_kind)) | 1415 ? Add<HLoadNamedField>(object, HObjectAccess::ForArrayLength(from_kind)) |
| 1416 : elements_length; | 1416 : elements_length; |
| 1417 | 1417 |
| 1418 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, | 1418 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, |
| 1419 array_length, elements_length); | 1419 array_length, elements_length); |
| 1420 | 1420 |
| 1421 if_builder.End(); | 1421 if_builder.End(); |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map); | 1424 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map, |
| 1425 INITIALIZING_STORE); | |
| 1425 } | 1426 } |
| 1426 | 1427 |
| 1427 | 1428 |
| 1428 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper( | 1429 HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper( |
| 1429 HValue* elements, | 1430 HValue* elements, |
| 1430 HValue* key, | 1431 HValue* key, |
| 1431 HValue* hash, | 1432 HValue* hash, |
| 1432 HValue* mask, | 1433 HValue* mask, |
| 1433 int current_probe) { | 1434 int current_probe) { |
| 1434 if (current_probe == kNumberDictionaryProbes) { | 1435 if (current_probe == kNumberDictionaryProbes) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1801 if_onebyte.Else(); | 1802 if_onebyte.Else(); |
| 1802 { | 1803 { |
| 1803 // We can safely skip the write barrier for storing the map here. | 1804 // We can safely skip the write barrier for storing the map here. |
| 1804 Handle<Map> map = isolate()->factory()->cons_string_map(); | 1805 Handle<Map> map = isolate()->factory()->cons_string_map(); |
| 1805 AddStoreMapConstantNoWriteBarrier(result, map); | 1806 AddStoreMapConstantNoWriteBarrier(result, map); |
| 1806 } | 1807 } |
| 1807 if_onebyte.End(); | 1808 if_onebyte.End(); |
| 1808 | 1809 |
| 1809 // Initialize the cons string fields. | 1810 // Initialize the cons string fields. |
| 1810 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), | 1811 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), |
| 1811 Add<HConstant>(String::kEmptyHashField)); | 1812 Add<HConstant>(String::kEmptyHashField), |
| 1812 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length); | 1813 INITIALIZING_STORE); |
| 1813 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left); | 1814 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length, |
| 1814 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right); | 1815 INITIALIZING_STORE); |
| 1816 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left, | |
| 1817 INITIALIZING_STORE); | |
| 1818 Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right, | |
| 1819 INITIALIZING_STORE); | |
| 1815 | 1820 |
| 1816 // Count the native string addition. | 1821 // Count the native string addition. |
| 1817 AddIncrementCounter(isolate()->counters()->string_add_native()); | 1822 AddIncrementCounter(isolate()->counters()->string_add_native()); |
| 1818 | 1823 |
| 1819 return result; | 1824 return result; |
| 1820 } | 1825 } |
| 1821 | 1826 |
| 1822 | 1827 |
| 1823 void HGraphBuilder::BuildCopySeqStringChars(HValue* src, | 1828 void HGraphBuilder::BuildCopySeqStringChars(HValue* src, |
| 1824 HValue* src_offset, | 1829 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 | 1958 // 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. | 1959 // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here. |
| 1955 HAllocate* result = BuildAllocate( | 1960 HAllocate* result = BuildAllocate( |
| 1956 size, HType::String(), STRING_TYPE, allocation_mode); | 1961 size, HType::String(), STRING_TYPE, allocation_mode); |
| 1957 | 1962 |
| 1958 // We can safely skip the write barrier for storing map here. | 1963 // We can safely skip the write barrier for storing map here. |
| 1959 AddStoreMapNoWriteBarrier(result, map); | 1964 AddStoreMapNoWriteBarrier(result, map); |
| 1960 | 1965 |
| 1961 // Initialize the string fields. | 1966 // Initialize the string fields. |
| 1962 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), | 1967 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), |
| 1963 Add<HConstant>(String::kEmptyHashField)); | 1968 Add<HConstant>(String::kEmptyHashField), |
| 1964 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length); | 1969 INITIALIZING_STORE); |
| 1970 Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length, | |
| 1971 INITIALIZING_STORE); | |
| 1965 | 1972 |
| 1966 // Copy characters to the result string. | 1973 // Copy characters to the result string. |
| 1967 IfBuilder if_twobyte(this); | 1974 IfBuilder if_twobyte(this); |
| 1968 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); | 1975 if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); |
| 1969 if_twobyte.Then(); | 1976 if_twobyte.Then(); |
| 1970 { | 1977 { |
| 1971 // Copy characters from the left string. | 1978 // Copy characters from the left string. |
| 1972 BuildCopySeqStringChars( | 1979 BuildCopySeqStringChars( |
| 1973 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, | 1980 left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, |
| 1974 result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, | 1981 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, | 2258 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, |
| 2252 ElementsKind kind, | 2259 ElementsKind kind, |
| 2253 HValue* capacity) { | 2260 HValue* capacity) { |
| 2254 Factory* factory = isolate()->factory(); | 2261 Factory* factory = isolate()->factory(); |
| 2255 Handle<Map> map = IsFastDoubleElementsKind(kind) | 2262 Handle<Map> map = IsFastDoubleElementsKind(kind) |
| 2256 ? factory->fixed_double_array_map() | 2263 ? factory->fixed_double_array_map() |
| 2257 : factory->fixed_array_map(); | 2264 : factory->fixed_array_map(); |
| 2258 | 2265 |
| 2259 AddStoreMapConstant(elements, map); | 2266 AddStoreMapConstant(elements, map); |
| 2260 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), | 2267 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), |
| 2261 capacity); | 2268 capacity, INITIALIZING_STORE); |
| 2262 } | 2269 } |
| 2263 | 2270 |
| 2264 | 2271 |
| 2265 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( | 2272 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( |
| 2266 ElementsKind kind, | 2273 ElementsKind kind, |
| 2267 HValue* capacity) { | 2274 HValue* capacity) { |
| 2268 // The HForceRepresentation is to prevent possible deopt on int-smi | 2275 // The HForceRepresentation is to prevent possible deopt on int-smi |
| 2269 // conversion after allocation but before the new object fields are set. | 2276 // conversion after allocation but before the new object fields are set. |
| 2270 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); | 2277 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); |
| 2271 HValue* new_elements = BuildAllocateElements(kind, capacity); | 2278 HValue* new_elements = BuildAllocateElements(kind, capacity); |
| 2272 BuildInitializeElementsHeader(new_elements, kind, capacity); | 2279 BuildInitializeElementsHeader(new_elements, kind, capacity); |
| 2273 return new_elements; | 2280 return new_elements; |
| 2274 } | 2281 } |
| 2275 | 2282 |
| 2276 | 2283 |
| 2277 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, | 2284 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, |
| 2278 HValue* array_map, | 2285 HValue* array_map, |
| 2279 AllocationSiteMode mode, | 2286 AllocationSiteMode mode, |
| 2280 ElementsKind elements_kind, | 2287 ElementsKind elements_kind, |
| 2281 HValue* allocation_site_payload, | 2288 HValue* allocation_site_payload, |
| 2282 HValue* length_field) { | 2289 HValue* length_field) { |
| 2283 | 2290 |
| 2284 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map); | 2291 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map, |
| 2292 INITIALIZING_STORE); | |
| 2285 | 2293 |
| 2286 HConstant* empty_fixed_array = | 2294 HConstant* empty_fixed_array = |
| 2287 Add<HConstant>(isolate()->factory()->empty_fixed_array()); | 2295 Add<HConstant>(isolate()->factory()->empty_fixed_array()); |
| 2288 | 2296 |
| 2289 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 2297 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
| 2290 Add<HStoreNamedField>(array, access, empty_fixed_array); | 2298 Add<HStoreNamedField>(array, access, empty_fixed_array, INITIALIZING_STORE); |
| 2291 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), | 2299 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), |
| 2292 length_field); | 2300 length_field, INITIALIZING_STORE); |
| 2293 | 2301 |
| 2294 if (mode == TRACK_ALLOCATION_SITE) { | 2302 if (mode == TRACK_ALLOCATION_SITE) { |
| 2295 BuildCreateAllocationMemento( | 2303 BuildCreateAllocationMemento( |
| 2296 array, Add<HConstant>(JSArray::kSize), allocation_site_payload); | 2304 array, Add<HConstant>(JSArray::kSize), allocation_site_payload); |
| 2297 } | 2305 } |
| 2298 | 2306 |
| 2299 int elements_location = JSArray::kSize; | 2307 int elements_location = JSArray::kSize; |
| 2300 if (mode == TRACK_ALLOCATION_SITE) { | 2308 if (mode == TRACK_ALLOCATION_SITE) { |
| 2301 elements_location += AllocationMemento::kSize; | 2309 elements_location += AllocationMemento::kSize; |
| 2302 } | 2310 } |
| 2303 | 2311 |
| 2304 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>( | 2312 HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>( |
| 2305 array, Add<HConstant>(elements_location)); | 2313 array, Add<HConstant>(elements_location)); |
| 2306 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements); | 2314 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements, |
| 2315 INITIALIZING_STORE); | |
| 2307 return elements; | 2316 return elements; |
| 2308 } | 2317 } |
| 2309 | 2318 |
| 2310 | 2319 |
| 2311 HInstruction* HGraphBuilder::AddElementAccess( | 2320 HInstruction* HGraphBuilder::AddElementAccess( |
| 2312 HValue* elements, | 2321 HValue* elements, |
| 2313 HValue* checked_key, | 2322 HValue* checked_key, |
| 2314 HValue* val, | 2323 HValue* val, |
| 2315 HValue* dependency, | 2324 HValue* dependency, |
| 2316 ElementsKind elements_kind, | 2325 ElementsKind elements_kind, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2387 BuildNewSpaceArrayCheck(new_capacity, new_kind); | 2396 BuildNewSpaceArrayCheck(new_capacity, new_kind); |
| 2388 | 2397 |
| 2389 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( | 2398 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( |
| 2390 new_kind, new_capacity); | 2399 new_kind, new_capacity); |
| 2391 | 2400 |
| 2392 BuildCopyElements(elements, kind, | 2401 BuildCopyElements(elements, kind, |
| 2393 new_elements, new_kind, | 2402 new_elements, new_kind, |
| 2394 length, new_capacity); | 2403 length, new_capacity); |
| 2395 | 2404 |
| 2396 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 2405 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 2397 new_elements); | 2406 new_elements, INITIALIZING_STORE); |
| 2398 | 2407 |
| 2399 return new_elements; | 2408 return new_elements; |
| 2400 } | 2409 } |
| 2401 | 2410 |
| 2402 | 2411 |
| 2403 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, | 2412 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, |
| 2404 ElementsKind elements_kind, | 2413 ElementsKind elements_kind, |
| 2405 HValue* from, | 2414 HValue* from, |
| 2406 HValue* to) { | 2415 HValue* to) { |
| 2407 // Fast elements kinds need to be initialized in case statements below cause | 2416 // Fast elements kinds need to be initialized in case statements below cause |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2428 | 2437 |
| 2429 // Since we're about to store a hole value, the store instruction below must | 2438 // Since we're about to store a hole value, the store instruction below must |
| 2430 // assume an elements kind that supports heap object values. | 2439 // assume an elements kind that supports heap object values. |
| 2431 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 2440 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
| 2432 elements_kind = FAST_HOLEY_ELEMENTS; | 2441 elements_kind = FAST_HOLEY_ELEMENTS; |
| 2433 } | 2442 } |
| 2434 | 2443 |
| 2435 if (initial_capacity >= 0) { | 2444 if (initial_capacity >= 0) { |
| 2436 for (int i = 0; i < initial_capacity; i++) { | 2445 for (int i = 0; i < initial_capacity; i++) { |
| 2437 HInstruction* key = Add<HConstant>(i); | 2446 HInstruction* key = Add<HConstant>(i); |
| 2438 Add<HStoreKeyed>(elements, key, hole, elements_kind); | 2447 Add<HStoreKeyed>(elements, key, hole, elements_kind, |
| 2448 PREINITIALIZING_STORE); | |
| 2439 } | 2449 } |
| 2440 } else { | 2450 } else { |
| 2441 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); | 2451 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); |
| 2442 | 2452 |
| 2443 HValue* key = builder.BeginBody(from, to, Token::LT); | 2453 HValue* key = builder.BeginBody(from, to, Token::LT); |
| 2444 | 2454 |
| 2445 Add<HStoreKeyed>(elements, key, hole, elements_kind); | 2455 Add<HStoreKeyed>(elements, key, hole, elements_kind, PREINITIALIZING_STORE); |
| 2446 | 2456 |
| 2447 builder.EndBody(); | 2457 builder.EndBody(); |
| 2448 } | 2458 } |
| 2449 } | 2459 } |
| 2450 | 2460 |
| 2451 | 2461 |
| 2452 void HGraphBuilder::BuildCopyElements(HValue* from_elements, | 2462 void HGraphBuilder::BuildCopyElements(HValue* from_elements, |
| 2453 ElementsKind from_elements_kind, | 2463 ElementsKind from_elements_kind, |
| 2454 HValue* to_elements, | 2464 HValue* to_elements, |
| 2455 ElementsKind to_elements_kind, | 2465 ElementsKind to_elements_kind, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2525 HInstruction* object = Add<HAllocate>(size_in_bytes, | 2535 HInstruction* object = Add<HAllocate>(size_in_bytes, |
| 2526 HType::JSObject(), | 2536 HType::JSObject(), |
| 2527 NOT_TENURED, | 2537 NOT_TENURED, |
| 2528 JS_OBJECT_TYPE); | 2538 JS_OBJECT_TYPE); |
| 2529 | 2539 |
| 2530 // Copy the JS array part. | 2540 // Copy the JS array part. |
| 2531 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 2541 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
| 2532 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 2542 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
| 2533 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); | 2543 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
| 2534 Add<HStoreNamedField>(object, access, | 2544 Add<HStoreNamedField>(object, access, |
| 2535 Add<HLoadNamedField>(boilerplate, access)); | 2545 Add<HLoadNamedField>(boilerplate, access), |
| 2546 INITIALIZING_STORE); | |
| 2536 } | 2547 } |
| 2537 } | 2548 } |
| 2538 | 2549 |
| 2539 // Create an allocation site info if requested. | 2550 // Create an allocation site info if requested. |
| 2540 if (mode == TRACK_ALLOCATION_SITE) { | 2551 if (mode == TRACK_ALLOCATION_SITE) { |
| 2541 BuildCreateAllocationMemento( | 2552 BuildCreateAllocationMemento( |
| 2542 object, Add<HConstant>(JSArray::kSize), allocation_site); | 2553 object, Add<HConstant>(JSArray::kSize), allocation_site); |
| 2543 } | 2554 } |
| 2544 | 2555 |
| 2545 if (length > 0) { | 2556 if (length > 0) { |
| 2546 HValue* boilerplate_elements = AddLoadElements(boilerplate); | 2557 HValue* boilerplate_elements = AddLoadElements(boilerplate); |
| 2547 HValue* object_elements; | 2558 HValue* object_elements; |
| 2548 if (IsFastDoubleElementsKind(kind)) { | 2559 if (IsFastDoubleElementsKind(kind)) { |
| 2549 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); | 2560 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); |
| 2550 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | 2561 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), |
| 2551 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); | 2562 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); |
| 2552 } else { | 2563 } else { |
| 2553 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); | 2564 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); |
| 2554 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | 2565 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), |
| 2555 NOT_TENURED, FIXED_ARRAY_TYPE); | 2566 NOT_TENURED, FIXED_ARRAY_TYPE); |
| 2556 } | 2567 } |
| 2557 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 2568 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 2558 object_elements); | 2569 object_elements, INITIALIZING_STORE); |
| 2559 | 2570 |
| 2560 // Copy the elements array header. | 2571 // Copy the elements array header. |
| 2561 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { | 2572 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { |
| 2562 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); | 2573 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); |
| 2563 Add<HStoreNamedField>(object_elements, access, | 2574 Add<HStoreNamedField>(object_elements, access, |
| 2564 Add<HLoadNamedField>(boilerplate_elements, access)); | 2575 Add<HLoadNamedField>(boilerplate_elements, access), |
| 2576 INITIALIZING_STORE); | |
| 2565 } | 2577 } |
| 2566 | 2578 |
| 2567 // Copy the elements array contents. | 2579 // Copy the elements array contents. |
| 2568 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold | 2580 // TODO(mstarzinger): Teach HGraphBuilder::BuildCopyElements to unfold |
| 2569 // copying loops with constant length up to a given boundary and use this | 2581 // copying loops with constant length up to a given boundary and use this |
| 2570 // helper here instead. | 2582 // helper here instead. |
| 2571 for (int i = 0; i < length; i++) { | 2583 for (int i = 0; i < length; i++) { |
| 2572 HValue* key_constant = Add<HConstant>(i); | 2584 HValue* key_constant = Add<HConstant>(i); |
| 2573 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, | 2585 HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant, |
| 2574 static_cast<HValue*>(NULL), kind); | 2586 static_cast<HValue*>(NULL), kind); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2635 void HGraphBuilder::BuildCreateAllocationMemento( | 2647 void HGraphBuilder::BuildCreateAllocationMemento( |
| 2636 HValue* previous_object, | 2648 HValue* previous_object, |
| 2637 HValue* previous_object_size, | 2649 HValue* previous_object_size, |
| 2638 HValue* allocation_site) { | 2650 HValue* allocation_site) { |
| 2639 ASSERT(allocation_site != NULL); | 2651 ASSERT(allocation_site != NULL); |
| 2640 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( | 2652 HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( |
| 2641 previous_object, previous_object_size); | 2653 previous_object, previous_object_size); |
| 2642 AddStoreMapConstant( | 2654 AddStoreMapConstant( |
| 2643 allocation_memento, isolate()->factory()->allocation_memento_map()); | 2655 allocation_memento, isolate()->factory()->allocation_memento_map()); |
| 2644 Add<HStoreNamedField>( | 2656 Add<HStoreNamedField>( |
| 2645 allocation_memento, | 2657 allocation_memento, HObjectAccess::ForAllocationMementoSite(), |
| 2646 HObjectAccess::ForAllocationMementoSite(), | 2658 allocation_site, INITIALIZING_STORE); |
| 2647 allocation_site); | |
| 2648 if (FLAG_allocation_site_pretenuring) { | 2659 if (FLAG_allocation_site_pretenuring) { |
| 2649 HValue* memento_create_count = Add<HLoadNamedField>( | 2660 HValue* memento_create_count = Add<HLoadNamedField>( |
| 2650 allocation_site, HObjectAccess::ForAllocationSiteOffset( | 2661 allocation_site, HObjectAccess::ForAllocationSiteOffset( |
| 2651 AllocationSite::kPretenureCreateCountOffset)); | 2662 AllocationSite::kPretenureCreateCountOffset)); |
| 2652 memento_create_count = AddUncasted<HAdd>( | 2663 memento_create_count = AddUncasted<HAdd>( |
| 2653 memento_create_count, graph()->GetConstant1()); | 2664 memento_create_count, graph()->GetConstant1()); |
| 2654 // This smi value is reset to zero after every gc, overflow isn't a problem | 2665 // 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. | 2666 // since the counter is bounded by the new space size. |
| 2656 memento_create_count->ClearFlag(HValue::kCanOverflow); | 2667 memento_create_count->ClearFlag(HValue::kCanOverflow); |
| 2657 HStoreNamedField* store = Add<HStoreNamedField>( | 2668 HStoreNamedField* store = Add<HStoreNamedField>( |
| 2658 allocation_site, HObjectAccess::ForAllocationSiteOffset( | 2669 allocation_site, HObjectAccess::ForAllocationSiteOffset( |
| 2659 AllocationSite::kPretenureCreateCountOffset), memento_create_count); | 2670 AllocationSite::kPretenureCreateCountOffset), memento_create_count, |
| 2671 INITIALIZING_STORE); | |
| 2660 // No write barrier needed to store a smi. | 2672 // No write barrier needed to store a smi. |
| 2661 store->SkipWriteBarrier(); | 2673 store->SkipWriteBarrier(); |
| 2662 } | 2674 } |
| 2663 } | 2675 } |
| 2664 | 2676 |
| 2665 | 2677 |
| 2666 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { | 2678 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { |
| 2667 // Get the global context, then the native context | 2679 // Get the global context, then the native context |
| 2668 HInstruction* context = | 2680 HInstruction* context = |
| 2669 Add<HLoadNamedField>(closure, HObjectAccess::ForFunctionContextPointer()); | 2681 Add<HLoadNamedField>(closure, HObjectAccess::ForFunctionContextPointer()); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2864 graph()->GetConstant0(), capacity); | 2876 graph()->GetConstant0(), capacity); |
| 2865 } | 2877 } |
| 2866 | 2878 |
| 2867 return new_object; | 2879 return new_object; |
| 2868 } | 2880 } |
| 2869 | 2881 |
| 2870 | 2882 |
| 2871 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, | 2883 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, |
| 2872 Handle<Map> map) { | 2884 Handle<Map> map) { |
| 2873 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), | 2885 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), |
| 2874 Add<HConstant>(map)); | 2886 Add<HConstant>(map), INITIALIZING_STORE); |
| 2875 } | 2887 } |
| 2876 | 2888 |
| 2877 | 2889 |
| 2878 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { | 2890 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { |
| 2879 HGlobalObject* global_object = Add<HGlobalObject>(); | 2891 HGlobalObject* global_object = Add<HGlobalObject>(); |
| 2880 HObjectAccess access = HObjectAccess::ForJSObjectOffset( | 2892 HObjectAccess access = HObjectAccess::ForJSObjectOffset( |
| 2881 GlobalObject::kBuiltinsOffset); | 2893 GlobalObject::kBuiltinsOffset); |
| 2882 HValue* builtins = Add<HLoadNamedField>(global_object, access); | 2894 HValue* builtins = Add<HLoadNamedField>(global_object, access); |
| 2883 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset( | 2895 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset( |
| 2884 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); | 2896 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); |
| (...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5256 field_access.WithRepresentation(Representation::Tagged()); | 5268 field_access.WithRepresentation(Representation::Tagged()); |
| 5257 if (transition_to_field) { | 5269 if (transition_to_field) { |
| 5258 // The store requires a mutable HeapNumber to be allocated. | 5270 // The store requires a mutable HeapNumber to be allocated. |
| 5259 NoObservableSideEffectsScope no_side_effects(this); | 5271 NoObservableSideEffectsScope no_side_effects(this); |
| 5260 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); | 5272 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); |
| 5261 HInstruction* heap_number = Add<HAllocate>(heap_number_size, | 5273 HInstruction* heap_number = Add<HAllocate>(heap_number_size, |
| 5262 HType::HeapNumber(), isolate()->heap()->GetPretenureMode(), | 5274 HType::HeapNumber(), isolate()->heap()->GetPretenureMode(), |
| 5263 HEAP_NUMBER_TYPE); | 5275 HEAP_NUMBER_TYPE); |
| 5264 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map()); | 5276 AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map()); |
| 5265 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), | 5277 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), |
| 5266 value); | 5278 value, INITIALIZING_STORE); |
| 5267 instr = New<HStoreNamedField>(checked_object->ActualValue(), | 5279 instr = New<HStoreNamedField>(checked_object->ActualValue(), |
| 5268 heap_number_access, | 5280 heap_number_access, |
| 5269 heap_number); | 5281 heap_number, INITIALIZING_STORE); |
| 5270 } else { | 5282 } else { |
| 5271 // Already holds a HeapNumber; load the box and write its value field. | 5283 // Already holds a HeapNumber; load the box and write its value field. |
| 5272 HInstruction* heap_number = Add<HLoadNamedField>(checked_object, | 5284 HInstruction* heap_number = Add<HLoadNamedField>(checked_object, |
| 5273 heap_number_access); | 5285 heap_number_access); |
| 5274 heap_number->set_type(HType::HeapNumber()); | 5286 heap_number->set_type(HType::HeapNumber()); |
| 5275 instr = New<HStoreNamedField>(heap_number, | 5287 instr = New<HStoreNamedField>(heap_number, |
| 5276 HObjectAccess::ForHeapNumberValue(), | 5288 HObjectAccess::ForHeapNumberValue(), |
| 5277 value); | 5289 value, STORE_TO_INITIALIZED_ENTRY); |
|
Igor Sheludko
2014/01/27 15:14:16
The heap number should have been initialized when
| |
| 5278 } | 5290 } |
| 5279 } else { | 5291 } else { |
| 5280 // This is a normal store. | 5292 // This is a normal store. |
| 5281 instr = New<HStoreNamedField>( | 5293 instr = New<HStoreNamedField>( |
| 5282 checked_object->ActualValue(), field_access, value, | 5294 checked_object->ActualValue(), field_access, value, |
| 5283 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); | 5295 transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); |
| 5284 } | 5296 } |
| 5285 | 5297 |
| 5286 if (transition_to_field) { | 5298 if (transition_to_field) { |
| 5287 Handle<Map> transition(lookup->GetTransitionMapFromMap(*map)); | 5299 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()) | 7659 ? Add<HConstant>(factory->the_hole_value()) |
| 7648 : Add<HConstant>(nan_double); | 7660 : Add<HConstant>(nan_double); |
| 7649 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 7661 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
| 7650 elements_kind = FAST_HOLEY_ELEMENTS; | 7662 elements_kind = FAST_HOLEY_ELEMENTS; |
| 7651 } | 7663 } |
| 7652 AddElementAccess( | 7664 AddElementAccess( |
| 7653 elements, reduced_length, hole, bounds_check, elements_kind, true); | 7665 elements, reduced_length, hole, bounds_check, elements_kind, true); |
| 7654 } | 7666 } |
| 7655 Add<HStoreNamedField>( | 7667 Add<HStoreNamedField>( |
| 7656 checked_object, HObjectAccess::ForArrayLength(elements_kind), | 7668 checked_object, HObjectAccess::ForArrayLength(elements_kind), |
| 7657 reduced_length); | 7669 reduced_length, STORE_TO_INITIALIZED_ENTRY); |
|
Igor Sheludko
2014/01/27 15:14:16
The array length should have been initialized earl
| |
| 7658 if (!ast_context()->IsEffect()) Push(result); | 7670 if (!ast_context()->IsEffect()) Push(result); |
| 7659 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); | 7671 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); |
| 7660 if (!ast_context()->IsEffect()) Drop(1); | 7672 if (!ast_context()->IsEffect()) Drop(1); |
| 7661 ast_context()->ReturnValue(result); | 7673 ast_context()->ReturnValue(result); |
| 7662 return true; | 7674 return true; |
| 7663 } | 7675 } |
| 7664 case kArrayPush: { | 7676 case kArrayPush: { |
| 7665 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { | 7677 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { |
| 7666 return false; | 7678 return false; |
| 7667 } | 7679 } |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8185 HValue* constructor_value = Add<HConstant>(constructor); | 8197 HValue* constructor_value = Add<HConstant>(constructor); |
| 8186 HValue* initial_map_value = | 8198 HValue* initial_map_value = |
| 8187 Add<HLoadNamedField>(constructor_value, HObjectAccess::ForJSObjectOffset( | 8199 Add<HLoadNamedField>(constructor_value, HObjectAccess::ForJSObjectOffset( |
| 8188 JSFunction::kPrototypeOrInitialMapOffset)); | 8200 JSFunction::kPrototypeOrInitialMapOffset)); |
| 8189 | 8201 |
| 8190 // Initialize map and fields of the newly allocated object. | 8202 // Initialize map and fields of the newly allocated object. |
| 8191 { NoObservableSideEffectsScope no_effects(this); | 8203 { NoObservableSideEffectsScope no_effects(this); |
| 8192 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); | 8204 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); |
| 8193 Add<HStoreNamedField>(receiver, | 8205 Add<HStoreNamedField>(receiver, |
| 8194 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), | 8206 HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset), |
| 8195 initial_map_value); | 8207 initial_map_value, INITIALIZING_STORE); |
| 8196 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); | 8208 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); |
| 8197 Add<HStoreNamedField>(receiver, | 8209 Add<HStoreNamedField>(receiver, |
| 8198 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), | 8210 HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset), |
| 8199 empty_fixed_array); | 8211 empty_fixed_array, INITIALIZING_STORE); |
| 8200 Add<HStoreNamedField>(receiver, | 8212 Add<HStoreNamedField>(receiver, |
| 8201 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), | 8213 HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset), |
| 8202 empty_fixed_array); | 8214 empty_fixed_array, INITIALIZING_STORE); |
| 8203 if (initial_map->inobject_properties() != 0) { | 8215 if (initial_map->inobject_properties() != 0) { |
| 8204 HConstant* undefined = graph()->GetConstantUndefined(); | 8216 HConstant* undefined = graph()->GetConstantUndefined(); |
| 8205 for (int i = 0; i < initial_map->inobject_properties(); i++) { | 8217 for (int i = 0; i < initial_map->inobject_properties(); i++) { |
| 8206 int property_offset = JSObject::kHeaderSize + i * kPointerSize; | 8218 int property_offset = JSObject::kHeaderSize + i * kPointerSize; |
| 8207 Add<HStoreNamedField>(receiver, | 8219 Add<HStoreNamedField>(receiver, |
| 8208 HObjectAccess::ForJSObjectOffset(property_offset), | 8220 HObjectAccess::ForJSObjectOffset(property_offset), |
| 8209 undefined); | 8221 undefined, PREINITIALIZING_STORE); |
| 8210 } | 8222 } |
| 8211 } | 8223 } |
| 8212 } | 8224 } |
| 8213 | 8225 |
| 8214 // Replace the constructor function with a newly allocated receiver using | 8226 // Replace the constructor function with a newly allocated receiver using |
| 8215 // the index of the receiver from the top of the expression stack. | 8227 // the index of the receiver from the top of the expression stack. |
| 8216 const int receiver_index = argument_count - 1; | 8228 const int receiver_index = argument_count - 1; |
| 8217 ASSERT(environment()->ExpressionStackAt(receiver_index) == function); | 8229 ASSERT(environment()->ExpressionStackAt(receiver_index) == function); |
| 8218 environment()->SetExpressionStackAt(receiver_index, receiver); | 8230 environment()->SetExpressionStackAt(receiver_index, receiver); |
| 8219 | 8231 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8284 HValue* obj, | 8296 HValue* obj, |
| 8285 HValue* buffer, | 8297 HValue* buffer, |
| 8286 HValue* byte_offset, | 8298 HValue* byte_offset, |
| 8287 HValue* byte_length) { | 8299 HValue* byte_length) { |
| 8288 | 8300 |
| 8289 for (int offset = ViewClass::kSize; | 8301 for (int offset = ViewClass::kSize; |
| 8290 offset < ViewClass::kSizeWithInternalFields; | 8302 offset < ViewClass::kSizeWithInternalFields; |
| 8291 offset += kPointerSize) { | 8303 offset += kPointerSize) { |
| 8292 Add<HStoreNamedField>(obj, | 8304 Add<HStoreNamedField>(obj, |
| 8293 HObjectAccess::ForJSObjectOffset(offset), | 8305 HObjectAccess::ForJSObjectOffset(offset), |
| 8294 Add<HConstant>(static_cast<int32_t>(0))); | 8306 graph()->GetConstant0(), INITIALIZING_STORE); |
| 8295 } | 8307 } |
| 8296 | 8308 |
| 8297 Add<HStoreNamedField>( | 8309 Add<HStoreNamedField>( |
| 8298 obj, | 8310 obj, |
| 8299 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); | 8311 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer, INITIALIZING_STORE); |
| 8300 Add<HStoreNamedField>( | 8312 Add<HStoreNamedField>( |
| 8301 obj, | 8313 obj, |
| 8302 HObjectAccess::ForJSArrayBufferViewByteOffset(), | 8314 HObjectAccess::ForJSArrayBufferViewByteOffset(), |
| 8303 byte_offset); | 8315 byte_offset, INITIALIZING_STORE); |
| 8304 Add<HStoreNamedField>( | 8316 Add<HStoreNamedField>( |
| 8305 obj, | 8317 obj, |
| 8306 HObjectAccess::ForJSArrayBufferViewByteLength(), | 8318 HObjectAccess::ForJSArrayBufferViewByteLength(), |
| 8307 byte_length); | 8319 byte_length, INITIALIZING_STORE); |
| 8308 | 8320 |
| 8309 HObjectAccess weak_first_view_access = | 8321 HObjectAccess weak_first_view_access = |
| 8310 HObjectAccess::ForJSArrayBufferWeakFirstView(); | 8322 HObjectAccess::ForJSArrayBufferWeakFirstView(); |
| 8311 Add<HStoreNamedField>(obj, | 8323 Add<HStoreNamedField>(obj, |
| 8312 HObjectAccess::ForJSArrayBufferViewWeakNext(), | 8324 HObjectAccess::ForJSArrayBufferViewWeakNext(), |
| 8313 Add<HLoadNamedField>(buffer, weak_first_view_access)); | 8325 Add<HLoadNamedField>(buffer, weak_first_view_access), |
| 8314 Add<HStoreNamedField>(buffer, weak_first_view_access, obj); | 8326 INITIALIZING_STORE); |
| 8327 Add<HStoreNamedField>( | |
| 8328 buffer, weak_first_view_access, obj, INITIALIZING_STORE); | |
| 8315 } | 8329 } |
| 8316 | 8330 |
| 8317 | 8331 |
| 8318 void HOptimizedGraphBuilder::VisitDataViewInitialize( | 8332 void HOptimizedGraphBuilder::VisitDataViewInitialize( |
| 8319 CallRuntime* expr) { | 8333 CallRuntime* expr) { |
| 8320 ZoneList<Expression*>* arguments = expr->arguments(); | 8334 ZoneList<Expression*>* arguments = expr->arguments(); |
| 8321 | 8335 |
| 8322 NoObservableSideEffectsScope scope(this); | 8336 NoObservableSideEffectsScope scope(this); |
| 8323 ASSERT(arguments->length()== 4); | 8337 ASSERT(arguments->length()== 4); |
| 8324 CHECK_ALIVE(VisitForValue(arguments->at(0))); | 8338 CHECK_ALIVE(VisitForValue(arguments->at(0))); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8394 | 8408 |
| 8395 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 8409 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
| 8396 size_t element_size = 1; // Bogus initialization. | 8410 size_t element_size = 1; // Bogus initialization. |
| 8397 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size); | 8411 Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &element_size); |
| 8398 | 8412 |
| 8399 HInstruction* length = AddUncasted<HDiv>(byte_length, | 8413 HInstruction* length = AddUncasted<HDiv>(byte_length, |
| 8400 Add<HConstant>(static_cast<int32_t>(element_size))); | 8414 Add<HConstant>(static_cast<int32_t>(element_size))); |
| 8401 | 8415 |
| 8402 Add<HStoreNamedField>(obj, | 8416 Add<HStoreNamedField>(obj, |
| 8403 HObjectAccess::ForJSTypedArrayLength(), | 8417 HObjectAccess::ForJSTypedArrayLength(), |
| 8404 length); | 8418 length, INITIALIZING_STORE); |
| 8405 | 8419 |
| 8406 HValue* elements = | 8420 HValue* elements = |
| 8407 Add<HAllocate>( | 8421 Add<HAllocate>( |
| 8408 Add<HConstant>(ExternalArray::kAlignedSize), | 8422 Add<HConstant>(ExternalArray::kAlignedSize), |
| 8409 HType::JSArray(), | 8423 HType::JSArray(), |
| 8410 NOT_TENURED, | 8424 NOT_TENURED, |
| 8411 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type)); | 8425 static_cast<InstanceType>(FIRST_EXTERNAL_ARRAY_TYPE + array_type)); |
| 8412 | 8426 |
| 8413 Handle<Map> external_array_map( | 8427 Handle<Map> external_array_map( |
| 8414 isolate()->heap()->MapForExternalArrayType(array_type)); | 8428 isolate()->heap()->MapForExternalArrayType(array_type)); |
| 8415 Add<HStoreNamedField>(elements, | 8429 AddStoreMapConstant(elements, external_array_map); |
| 8416 HObjectAccess::ForMap(), | |
| 8417 Add<HConstant>(external_array_map)); | |
| 8418 | 8430 |
| 8419 HValue* backing_store = Add<HLoadNamedField>( | 8431 HValue* backing_store = Add<HLoadNamedField>( |
| 8420 buffer, HObjectAccess::ForJSArrayBufferBackingStore()); | 8432 buffer, HObjectAccess::ForJSArrayBufferBackingStore()); |
| 8421 | 8433 |
| 8422 HValue* typed_array_start; | 8434 HValue* typed_array_start; |
| 8423 if (is_zero_byte_offset) { | 8435 if (is_zero_byte_offset) { |
| 8424 typed_array_start = backing_store; | 8436 typed_array_start = backing_store; |
| 8425 } else { | 8437 } else { |
| 8426 HInstruction* external_pointer = | 8438 HInstruction* external_pointer = |
| 8427 AddUncasted<HAdd>(backing_store, byte_offset); | 8439 AddUncasted<HAdd>(backing_store, byte_offset); |
| 8428 // Arguments are checked prior to call to TypedArrayInitialize, | 8440 // Arguments are checked prior to call to TypedArrayInitialize, |
| 8429 // including byte_offset. | 8441 // including byte_offset. |
| 8430 external_pointer->ClearFlag(HValue::kCanOverflow); | 8442 external_pointer->ClearFlag(HValue::kCanOverflow); |
| 8431 typed_array_start = external_pointer; | 8443 typed_array_start = external_pointer; |
| 8432 } | 8444 } |
| 8433 | 8445 |
| 8434 Add<HStoreNamedField>(elements, | |
| 8435 HObjectAccess::ForExternalArrayExternalPointer(), | |
| 8436 typed_array_start); | |
| 8437 Add<HStoreNamedField>(elements, | |
| 8438 HObjectAccess::ForFixedArrayLength(), | |
| 8439 length); | |
| 8440 Add<HStoreNamedField>( | 8446 Add<HStoreNamedField>( |
| 8441 obj, HObjectAccess::ForElementsPointer(), elements); | 8447 elements, HObjectAccess::ForExternalArrayExternalPointer(), |
| 8448 typed_array_start, INITIALIZING_STORE); | |
| 8449 Add<HStoreNamedField>( | |
| 8450 elements, HObjectAccess::ForFixedArrayLength(), length, | |
| 8451 INITIALIZING_STORE); | |
| 8452 Add<HStoreNamedField>( | |
| 8453 obj, HObjectAccess::ForElementsPointer(), elements, INITIALIZING_STORE); | |
| 8442 } | 8454 } |
| 8443 | 8455 |
| 8444 if (!is_zero_byte_offset) { | 8456 if (!is_zero_byte_offset) { |
| 8445 byte_offset_smi.Else(); | 8457 byte_offset_smi.Else(); |
| 8446 { // byte_offset is not Smi. | 8458 { // byte_offset is not Smi. |
| 8447 Push(Add<HPushArgument>(obj)); | 8459 Push(Add<HPushArgument>(obj)); |
| 8448 VisitArgument(arguments->at(kArrayIdArg)); | 8460 VisitArgument(arguments->at(kArrayIdArg)); |
| 8449 Push(Add<HPushArgument>(buffer)); | 8461 Push(Add<HPushArgument>(buffer)); |
| 8450 Push(Add<HPushArgument>(byte_offset)); | 8462 Push(Add<HPushArgument>(byte_offset)); |
| 8451 Push(Add<HPushArgument>(byte_length)); | 8463 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); | 9680 ASSERT(boilerplate_object->properties()->length() == 0); |
| 9669 | 9681 |
| 9670 Handle<Map> boilerplate_object_map(boilerplate_object->map()); | 9682 Handle<Map> boilerplate_object_map(boilerplate_object->map()); |
| 9671 AddStoreMapConstant(object, boilerplate_object_map); | 9683 AddStoreMapConstant(object, boilerplate_object_map); |
| 9672 | 9684 |
| 9673 Handle<Object> properties_field = | 9685 Handle<Object> properties_field = |
| 9674 Handle<Object>(boilerplate_object->properties(), isolate()); | 9686 Handle<Object>(boilerplate_object->properties(), isolate()); |
| 9675 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); | 9687 ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); |
| 9676 HInstruction* properties = Add<HConstant>(properties_field); | 9688 HInstruction* properties = Add<HConstant>(properties_field); |
| 9677 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 9689 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
| 9678 Add<HStoreNamedField>(object, access, properties); | 9690 Add<HStoreNamedField>(object, access, properties, INITIALIZING_STORE); |
| 9679 | 9691 |
| 9680 if (boilerplate_object->IsJSArray()) { | 9692 if (boilerplate_object->IsJSArray()) { |
| 9681 Handle<JSArray> boilerplate_array = | 9693 Handle<JSArray> boilerplate_array = |
| 9682 Handle<JSArray>::cast(boilerplate_object); | 9694 Handle<JSArray>::cast(boilerplate_object); |
| 9683 Handle<Object> length_field = | 9695 Handle<Object> length_field = |
| 9684 Handle<Object>(boilerplate_array->length(), isolate()); | 9696 Handle<Object>(boilerplate_array->length(), isolate()); |
| 9685 HInstruction* length = Add<HConstant>(length_field); | 9697 HInstruction* length = Add<HConstant>(length_field); |
| 9686 | 9698 |
| 9687 ASSERT(boilerplate_array->length()->IsSmi()); | 9699 ASSERT(boilerplate_array->length()->IsSmi()); |
| 9688 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( | 9700 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( |
| 9689 boilerplate_array->GetElementsKind()), length); | 9701 boilerplate_array->GetElementsKind()), length, INITIALIZING_STORE); |
| 9690 } | 9702 } |
| 9691 } | 9703 } |
| 9692 | 9704 |
| 9693 | 9705 |
| 9694 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( | 9706 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( |
| 9695 Handle<JSObject> boilerplate_object, | 9707 Handle<JSObject> boilerplate_object, |
| 9696 HInstruction* object, | 9708 HInstruction* object, |
| 9697 HInstruction* object_elements) { | 9709 HInstruction* object_elements) { |
| 9698 ASSERT(boilerplate_object->properties()->length() == 0); | 9710 ASSERT(boilerplate_object->properties()->length() == 0); |
| 9699 if (object_elements == NULL) { | 9711 if (object_elements == NULL) { |
| 9700 Handle<Object> elements_field = | 9712 Handle<Object> elements_field = |
| 9701 Handle<Object>(boilerplate_object->elements(), isolate()); | 9713 Handle<Object>(boilerplate_object->elements(), isolate()); |
| 9702 object_elements = Add<HConstant>(elements_field); | 9714 object_elements = Add<HConstant>(elements_field); |
| 9703 } | 9715 } |
| 9704 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 9716 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 9705 object_elements); | 9717 object_elements, INITIALIZING_STORE); |
| 9706 } | 9718 } |
| 9707 | 9719 |
| 9708 | 9720 |
| 9709 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( | 9721 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( |
| 9710 Handle<JSObject> boilerplate_object, | 9722 Handle<JSObject> boilerplate_object, |
| 9711 HInstruction* object, | 9723 HInstruction* object, |
| 9712 AllocationSiteUsageContext* site_context, | 9724 AllocationSiteUsageContext* site_context, |
| 9713 PretenureFlag pretenure_flag) { | 9725 PretenureFlag pretenure_flag) { |
| 9714 Handle<DescriptorArray> descriptors( | 9726 Handle<DescriptorArray> descriptors( |
| 9715 boilerplate_object->map()->instance_descriptors()); | 9727 boilerplate_object->map()->instance_descriptors()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 9731 HObjectAccess access = boilerplate_object->IsJSArray() ? | 9743 HObjectAccess access = boilerplate_object->IsJSArray() ? |
| 9732 HObjectAccess::ForJSArrayOffset(property_offset) : | 9744 HObjectAccess::ForJSArrayOffset(property_offset) : |
| 9733 HObjectAccess::ForJSObjectOffset(property_offset); | 9745 HObjectAccess::ForJSObjectOffset(property_offset); |
| 9734 | 9746 |
| 9735 if (value->IsJSObject()) { | 9747 if (value->IsJSObject()) { |
| 9736 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 9748 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
| 9737 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 9749 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
| 9738 HInstruction* result = | 9750 HInstruction* result = |
| 9739 BuildFastLiteral(value_object, site_context); | 9751 BuildFastLiteral(value_object, site_context); |
| 9740 site_context->ExitScope(current_site, value_object); | 9752 site_context->ExitScope(current_site, value_object); |
| 9741 Add<HStoreNamedField>(object, access, result); | 9753 Add<HStoreNamedField>(object, access, result, INITIALIZING_STORE); |
| 9742 } else { | 9754 } else { |
| 9743 Representation representation = details.representation(); | 9755 Representation representation = details.representation(); |
| 9744 HInstruction* value_instruction; | 9756 HInstruction* value_instruction; |
| 9745 | 9757 |
| 9746 if (representation.IsDouble()) { | 9758 if (representation.IsDouble()) { |
| 9747 // Allocate a HeapNumber box and store the value into it. | 9759 // Allocate a HeapNumber box and store the value into it. |
| 9748 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); | 9760 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); |
| 9749 // This heap number alloc does not have a corresponding | 9761 // This heap number alloc does not have a corresponding |
| 9750 // AllocationSite. That is okay because | 9762 // AllocationSite. That is okay because |
| 9751 // 1) it's a child object of another object with a valid allocation site | 9763 // 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 | 9764 // 2) we can just use the mode of the parent object for pretenuring |
| 9753 HInstruction* double_box = | 9765 HInstruction* double_box = |
| 9754 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), | 9766 Add<HAllocate>(heap_number_constant, HType::HeapNumber(), |
| 9755 pretenure_flag, HEAP_NUMBER_TYPE); | 9767 pretenure_flag, HEAP_NUMBER_TYPE); |
| 9756 AddStoreMapConstant(double_box, | 9768 AddStoreMapConstant(double_box, |
| 9757 isolate()->factory()->heap_number_map()); | 9769 isolate()->factory()->heap_number_map()); |
| 9758 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), | 9770 Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), |
| 9759 Add<HConstant>(value)); | 9771 Add<HConstant>(value), INITIALIZING_STORE); |
| 9760 value_instruction = double_box; | 9772 value_instruction = double_box; |
| 9761 } else if (representation.IsSmi() && value->IsUninitialized()) { | 9773 } else if (representation.IsSmi() && value->IsUninitialized()) { |
| 9762 value_instruction = graph()->GetConstant0(); | 9774 value_instruction = graph()->GetConstant0(); |
| 9763 } else { | 9775 } else { |
| 9764 value_instruction = Add<HConstant>(value); | 9776 value_instruction = Add<HConstant>(value); |
| 9765 } | 9777 } |
| 9766 | 9778 |
| 9767 Add<HStoreNamedField>(object, access, value_instruction); | 9779 Add<HStoreNamedField>(object, access, value_instruction, |
| 9780 INITIALIZING_STORE); | |
| 9768 } | 9781 } |
| 9769 } | 9782 } |
| 9770 | 9783 |
| 9771 int inobject_properties = boilerplate_object->map()->inobject_properties(); | 9784 int inobject_properties = boilerplate_object->map()->inobject_properties(); |
| 9772 HInstruction* value_instruction = | 9785 HInstruction* value_instruction = |
| 9773 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); | 9786 Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); |
| 9774 for (int i = copied_fields; i < inobject_properties; i++) { | 9787 for (int i = copied_fields; i < inobject_properties; i++) { |
| 9775 ASSERT(boilerplate_object->IsJSObject()); | 9788 ASSERT(boilerplate_object->IsJSObject()); |
| 9776 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); | 9789 int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); |
| 9777 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); | 9790 HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset); |
| 9778 Add<HStoreNamedField>(object, access, value_instruction); | 9791 Add<HStoreNamedField>(object, access, value_instruction, |
| 9792 PREINITIALIZING_STORE); | |
|
Igor Sheludko
2014/01/27 15:14:16
It seems that we are initializing data "outside" o
| |
| 9779 } | 9793 } |
| 9780 } | 9794 } |
| 9781 | 9795 |
| 9782 | 9796 |
| 9783 void HOptimizedGraphBuilder::BuildEmitElements( | 9797 void HOptimizedGraphBuilder::BuildEmitElements( |
| 9784 Handle<JSObject> boilerplate_object, | 9798 Handle<JSObject> boilerplate_object, |
| 9785 Handle<FixedArrayBase> elements, | 9799 Handle<FixedArrayBase> elements, |
| 9786 HValue* object_elements, | 9800 HValue* object_elements, |
| 9787 AllocationSiteUsageContext* site_context) { | 9801 AllocationSiteUsageContext* site_context) { |
| 9788 ElementsKind kind = boilerplate_object->map()->elements_kind(); | 9802 ElementsKind kind = boilerplate_object->map()->elements_kind(); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10221 HBasicBlock* if_js_value = graph()->CreateBasicBlock(); | 10235 HBasicBlock* if_js_value = graph()->CreateBasicBlock(); |
| 10222 HBasicBlock* not_js_value = graph()->CreateBasicBlock(); | 10236 HBasicBlock* not_js_value = graph()->CreateBasicBlock(); |
| 10223 typecheck->SetSuccessorAt(0, if_js_value); | 10237 typecheck->SetSuccessorAt(0, if_js_value); |
| 10224 typecheck->SetSuccessorAt(1, not_js_value); | 10238 typecheck->SetSuccessorAt(1, not_js_value); |
| 10225 FinishCurrentBlock(typecheck); | 10239 FinishCurrentBlock(typecheck); |
| 10226 Goto(not_js_value, join); | 10240 Goto(not_js_value, join); |
| 10227 | 10241 |
| 10228 // Create in-object property store to kValueOffset. | 10242 // Create in-object property store to kValueOffset. |
| 10229 set_current_block(if_js_value); | 10243 set_current_block(if_js_value); |
| 10230 Add<HStoreNamedField>(object, | 10244 Add<HStoreNamedField>(object, |
| 10231 HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), value); | 10245 HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), value, |
| 10246 INITIALIZING_STORE); | |
| 10232 Goto(if_js_value, join); | 10247 Goto(if_js_value, join); |
| 10233 join->SetJoinId(call->id()); | 10248 join->SetJoinId(call->id()); |
| 10234 set_current_block(join); | 10249 set_current_block(join); |
| 10235 return ast_context()->ReturnValue(value); | 10250 return ast_context()->ReturnValue(value); |
| 10236 } | 10251 } |
| 10237 | 10252 |
| 10238 | 10253 |
| 10239 // Fast support for charCodeAt(n). | 10254 // Fast support for charCodeAt(n). |
| 10240 void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { | 10255 void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { |
| 10241 ASSERT(call->arguments()->length() == 2); | 10256 ASSERT(call->arguments()->length() == 2); |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11083 if (ShouldProduceTraceOutput()) { | 11098 if (ShouldProduceTraceOutput()) { |
| 11084 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11099 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 11085 } | 11100 } |
| 11086 | 11101 |
| 11087 #ifdef DEBUG | 11102 #ifdef DEBUG |
| 11088 graph_->Verify(false); // No full verify. | 11103 graph_->Verify(false); // No full verify. |
| 11089 #endif | 11104 #endif |
| 11090 } | 11105 } |
| 11091 | 11106 |
| 11092 } } // namespace v8::internal | 11107 } } // namespace v8::internal |
| OLD | NEW |