| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 } | 594 } |
| 595 | 595 |
| 596 | 596 |
| 597 LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { | 597 LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { |
| 598 return value->IsConstant() | 598 return value->IsConstant() |
| 599 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | 599 ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 600 : UseRegisterAtStart(value); | 600 : UseRegisterAtStart(value); |
| 601 } | 601 } |
| 602 | 602 |
| 603 | 603 |
| 604 LOperand* LChunkBuilder::UseConstant(HValue* value) { |
| 605 return chunk_->DefineConstantOperand(HConstant::cast(value)); |
| 606 } |
| 607 |
| 608 |
| 604 LOperand* LChunkBuilder::UseAny(HValue* value) { | 609 LOperand* LChunkBuilder::UseAny(HValue* value) { |
| 605 return value->IsConstant() | 610 return value->IsConstant() |
| 606 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | 611 ? chunk_->DefineConstantOperand(HConstant::cast(value)) |
| 607 : Use(value, new(zone()) LUnallocated(LUnallocated::ANY)); | 612 : Use(value, new(zone()) LUnallocated(LUnallocated::ANY)); |
| 608 } | 613 } |
| 609 | 614 |
| 610 | 615 |
| 611 LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) { | 616 LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) { |
| 612 if (value->EmitAtUses()) { | 617 if (value->EmitAtUses()) { |
| 613 HInstruction* instr = HInstruction::cast(value); | 618 HInstruction* instr = HInstruction::cast(value); |
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2280 | 2285 |
| 2281 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && | 2286 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && |
| 2282 IsDoubleOrFloatElementsKind(elements_kind)) { | 2287 IsDoubleOrFloatElementsKind(elements_kind)) { |
| 2283 return UseRegisterAtStart(instr->value()); | 2288 return UseRegisterAtStart(instr->value()); |
| 2284 } | 2289 } |
| 2285 | 2290 |
| 2286 return UseRegister(instr->value()); | 2291 return UseRegister(instr->value()); |
| 2287 } | 2292 } |
| 2288 | 2293 |
| 2289 | 2294 |
| 2290 // DoStoreKeyed and DoStoreNamedField have special considerations for allowing | |
| 2291 // use of a constant instead of a register. | |
| 2292 static bool StoreConstantValueAllowed(HValue* value) { | |
| 2293 if (value->IsConstant()) { | |
| 2294 HConstant* constant_value = HConstant::cast(value); | |
| 2295 return constant_value->HasSmiValue() | |
| 2296 || constant_value->HasDoubleValue() | |
| 2297 || constant_value->ImmortalImmovable(); | |
| 2298 } | |
| 2299 return false; | |
| 2300 } | |
| 2301 | |
| 2302 | |
| 2303 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2295 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
| 2304 if (!instr->is_external()) { | 2296 if (!instr->is_external()) { |
| 2305 ASSERT(instr->elements()->representation().IsTagged()); | 2297 ASSERT(instr->elements()->representation().IsTagged()); |
| 2306 ASSERT(instr->key()->representation().IsInteger32() || | 2298 ASSERT(instr->key()->representation().IsInteger32() || |
| 2307 instr->key()->representation().IsTagged()); | 2299 instr->key()->representation().IsTagged()); |
| 2308 | 2300 |
| 2309 if (instr->value()->representation().IsDouble()) { | 2301 if (instr->value()->representation().IsDouble()) { |
| 2310 LOperand* object = UseRegisterAtStart(instr->elements()); | 2302 LOperand* object = UseRegisterAtStart(instr->elements()); |
| 2311 LOperand* val = NULL; | 2303 LOperand* val = NULL; |
| 2312 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { | 2304 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { |
| 2313 val = UseRegisterAtStart(instr->value()); | 2305 val = UseRegisterAtStart(instr->value()); |
| 2314 } else if (!instr->IsConstantHoleStore()) { | 2306 } else if (!instr->IsConstantHoleStore()) { |
| 2315 val = UseX87TopOfStack(instr->value()); | 2307 val = UseX87TopOfStack(instr->value()); |
| 2316 } | 2308 } |
| 2317 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2309 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
| 2318 return new(zone()) LStoreKeyed(object, key, val); | 2310 return new(zone()) LStoreKeyed(object, key, val); |
| 2319 } else { | 2311 } else { |
| 2320 ASSERT(instr->value()->representation().IsTagged()); | 2312 ASSERT(instr->value()->representation().IsTagged()); |
| 2321 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2313 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
| 2322 | 2314 |
| 2323 LOperand* obj = UseRegister(instr->elements()); | 2315 LOperand* obj = UseRegister(instr->elements()); |
| 2324 LOperand* val; | 2316 LOperand* val; |
| 2325 LOperand* key; | 2317 LOperand* key; |
| 2326 if (needs_write_barrier) { | 2318 if (needs_write_barrier) { |
| 2327 val = UseTempRegister(instr->value()); | 2319 val = UseTempRegister(instr->value()); |
| 2328 key = UseTempRegister(instr->key()); | 2320 key = UseTempRegister(instr->key()); |
| 2329 } else { | 2321 } else { |
| 2330 if (StoreConstantValueAllowed(instr->value())) { | 2322 val = UseRegisterOrConstantAtStart(instr->value()); |
| 2331 val = UseRegisterOrConstantAtStart(instr->value()); | 2323 key = UseRegisterOrConstantAtStart(instr->key()); |
| 2332 } else { | |
| 2333 val = UseRegisterAtStart(instr->value()); | |
| 2334 } | |
| 2335 | |
| 2336 if (StoreConstantValueAllowed(instr->key())) { | |
| 2337 key = UseRegisterOrConstantAtStart(instr->key()); | |
| 2338 } else { | |
| 2339 key = UseRegisterAtStart(instr->key()); | |
| 2340 } | |
| 2341 } | 2324 } |
| 2342 return new(zone()) LStoreKeyed(obj, key, val); | 2325 return new(zone()) LStoreKeyed(obj, key, val); |
| 2343 } | 2326 } |
| 2344 } | 2327 } |
| 2345 | 2328 |
| 2346 ElementsKind elements_kind = instr->elements_kind(); | 2329 ElementsKind elements_kind = instr->elements_kind(); |
| 2347 ASSERT( | 2330 ASSERT( |
| 2348 (instr->value()->representation().IsInteger32() && | 2331 (instr->value()->representation().IsInteger32() && |
| 2349 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2332 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2350 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2333 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2431 if (needs_write_barrier) { | 2414 if (needs_write_barrier) { |
| 2432 obj = instr->is_in_object() | 2415 obj = instr->is_in_object() |
| 2433 ? UseRegister(instr->object()) | 2416 ? UseRegister(instr->object()) |
| 2434 : UseTempRegister(instr->object()); | 2417 : UseTempRegister(instr->object()); |
| 2435 } else { | 2418 } else { |
| 2436 obj = needs_write_barrier_for_map | 2419 obj = needs_write_barrier_for_map |
| 2437 ? UseRegister(instr->object()) | 2420 ? UseRegister(instr->object()) |
| 2438 : UseRegisterAtStart(instr->object()); | 2421 : UseRegisterAtStart(instr->object()); |
| 2439 } | 2422 } |
| 2440 | 2423 |
| 2424 bool can_be_constant = instr->value()->IsConstant() && |
| 2425 !HConstant::cast(instr->value())->InNewSpace(); |
| 2426 |
| 2441 LOperand* val; | 2427 LOperand* val; |
| 2442 if (needs_write_barrier) { | 2428 if (needs_write_barrier) { |
| 2443 val = UseTempRegister(instr->value()); | 2429 val = UseTempRegister(instr->value()); |
| 2444 } else if (StoreConstantValueAllowed(instr->value())) { | 2430 } else if (can_be_constant) { |
| 2445 val = UseRegisterOrConstant(instr->value()); | 2431 val = UseRegisterOrConstant(instr->value()); |
| 2446 } else { | 2432 } else { |
| 2447 val = UseRegister(instr->value()); | 2433 val = UseRegister(instr->value()); |
| 2448 } | 2434 } |
| 2449 | 2435 |
| 2450 // We only need a scratch register if we have a write barrier or we | 2436 // We only need a scratch register if we have a write barrier or we |
| 2451 // have a store into the properties array (not in-object-property). | 2437 // have a store into the properties array (not in-object-property). |
| 2452 LOperand* temp = (!instr->is_in_object() || needs_write_barrier || | 2438 LOperand* temp = (!instr->is_in_object() || needs_write_barrier || |
| 2453 needs_write_barrier_for_map) ? TempRegister() : NULL; | 2439 needs_write_barrier_for_map) ? TempRegister() : NULL; |
| 2454 | 2440 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2509 LOperand* context = UseAny(instr->context()); | 2495 LOperand* context = UseAny(instr->context()); |
| 2510 LOperand* temp = TempRegister(); | 2496 LOperand* temp = TempRegister(); |
| 2511 LAllocateObject* result = new(zone()) LAllocateObject(context, temp); | 2497 LAllocateObject* result = new(zone()) LAllocateObject(context, temp); |
| 2512 return AssignPointerMap(DefineAsRegister(result)); | 2498 return AssignPointerMap(DefineAsRegister(result)); |
| 2513 } | 2499 } |
| 2514 | 2500 |
| 2515 | 2501 |
| 2516 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { | 2502 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { |
| 2517 info()->MarkAsDeferredCalling(); | 2503 info()->MarkAsDeferredCalling(); |
| 2518 LOperand* context = UseAny(instr->context()); | 2504 LOperand* context = UseAny(instr->context()); |
| 2519 // TODO(mvstanton): why can't size be a constant if possible? | 2505 LOperand* size = instr->size()->IsConstant() |
| 2520 LOperand* size = UseTempRegister(instr->size()); | 2506 ? UseConstant(instr->size()) |
| 2507 : UseTempRegister(instr->size()); |
| 2521 LOperand* temp = TempRegister(); | 2508 LOperand* temp = TempRegister(); |
| 2522 LAllocate* result = new(zone()) LAllocate(context, size, temp); | 2509 LAllocate* result = new(zone()) LAllocate(context, size, temp); |
| 2523 return AssignPointerMap(DefineAsRegister(result)); | 2510 return AssignPointerMap(DefineAsRegister(result)); |
| 2524 } | 2511 } |
| 2525 | 2512 |
| 2526 | 2513 |
| 2527 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { | 2514 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { |
| 2528 LOperand* context = UseFixed(instr->context(), esi); | 2515 LOperand* context = UseFixed(instr->context(), esi); |
| 2529 return MarkAsCall( | 2516 return MarkAsCall( |
| 2530 DefineFixed(new(zone()) LArrayLiteral(context), eax), instr); | 2517 DefineFixed(new(zone()) LArrayLiteral(context), eax), instr); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2774 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2761 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2775 LOperand* object = UseRegister(instr->object()); | 2762 LOperand* object = UseRegister(instr->object()); |
| 2776 LOperand* index = UseTempRegister(instr->index()); | 2763 LOperand* index = UseTempRegister(instr->index()); |
| 2777 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2764 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2778 } | 2765 } |
| 2779 | 2766 |
| 2780 | 2767 |
| 2781 } } // namespace v8::internal | 2768 } } // namespace v8::internal |
| 2782 | 2769 |
| 2783 #endif // V8_TARGET_ARCH_IA32 | 2770 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |