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

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 1263513002: VM: Load allocation-top and -end via Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed cc tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 RawPcDescriptors::kOther, 1679 RawPcDescriptors::kOther,
1680 locs); 1680 locs);
1681 __ MoveRegister(result_, RAX); 1681 __ MoveRegister(result_, RAX);
1682 compiler->RestoreLiveRegisters(locs); 1682 compiler->RestoreLiveRegisters(locs);
1683 __ jmp(exit_label()); 1683 __ jmp(exit_label());
1684 } 1684 }
1685 1685
1686 static void Allocate(FlowGraphCompiler* compiler, 1686 static void Allocate(FlowGraphCompiler* compiler,
1687 Instruction* instruction, 1687 Instruction* instruction,
1688 const Class& cls, 1688 const Class& cls,
1689 Register result) { 1689 Register result,
1690 Register temp) {
1690 if (compiler->intrinsic_mode()) { 1691 if (compiler->intrinsic_mode()) {
1691 __ TryAllocate(cls, 1692 __ TryAllocate(cls,
1692 compiler->intrinsic_slow_path_label(), 1693 compiler->intrinsic_slow_path_label(),
1693 Assembler::kFarJump, 1694 Assembler::kFarJump,
1694 result); 1695 result,
1696 temp);
1695 } else { 1697 } else {
1696 BoxAllocationSlowPath* slow_path = 1698 BoxAllocationSlowPath* slow_path =
1697 new BoxAllocationSlowPath(instruction, cls, result); 1699 new BoxAllocationSlowPath(instruction, cls, result);
1698 compiler->AddSlowPathCode(slow_path); 1700 compiler->AddSlowPathCode(slow_path);
1699 1701
1700 __ TryAllocate(cls, 1702 __ TryAllocate(cls,
1701 slow_path->entry_label(), 1703 slow_path->entry_label(),
1702 Assembler::kFarJump, 1704 Assembler::kFarJump,
1703 result); 1705 result,
1706 temp);
1704 __ Bind(slow_path->exit_label()); 1707 __ Bind(slow_path->exit_label());
1705 } 1708 }
1706 } 1709 }
1707 1710
1708 private: 1711 private:
1709 Instruction* instruction_; 1712 Instruction* instruction_;
1710 const Class& cls_; 1713 const Class& cls_;
1711 const Register result_; 1714 const Register result_;
1712 }; 1715 };
1713 1716
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 StoreInstanceFieldInstr* instruction, 1754 StoreInstanceFieldInstr* instruction,
1752 Register box_reg, 1755 Register box_reg,
1753 const Class& cls, 1756 const Class& cls,
1754 Register instance_reg, 1757 Register instance_reg,
1755 intptr_t offset, 1758 intptr_t offset,
1756 Register temp) { 1759 Register temp) {
1757 Label done; 1760 Label done;
1758 __ movq(box_reg, FieldAddress(instance_reg, offset)); 1761 __ movq(box_reg, FieldAddress(instance_reg, offset));
1759 __ CompareObject(box_reg, Object::null_object()); 1762 __ CompareObject(box_reg, Object::null_object());
1760 __ j(NOT_EQUAL, &done); 1763 __ j(NOT_EQUAL, &done);
1761 BoxAllocationSlowPath::Allocate(compiler, instruction, cls, box_reg); 1764 BoxAllocationSlowPath::Allocate(compiler, instruction, cls, box_reg, temp);
1762 __ movq(temp, box_reg); 1765 __ movq(temp, box_reg);
1763 __ StoreIntoObject(instance_reg, 1766 __ StoreIntoObject(instance_reg,
1764 FieldAddress(instance_reg, offset), 1767 FieldAddress(instance_reg, offset),
1765 temp); 1768 temp);
1766 1769
1767 __ Bind(&done); 1770 __ Bind(&done);
1768 } 1771 }
1769 1772
1770 1773
1771 void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1774 void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 17 matching lines...) Expand all
1789 case kFloat32x4Cid: 1792 case kFloat32x4Cid:
1790 cls = &compiler->float32x4_class(); 1793 cls = &compiler->float32x4_class();
1791 break; 1794 break;
1792 case kFloat64x2Cid: 1795 case kFloat64x2Cid:
1793 cls = &compiler->float64x2_class(); 1796 cls = &compiler->float64x2_class();
1794 break; 1797 break;
1795 default: 1798 default:
1796 UNREACHABLE(); 1799 UNREACHABLE();
1797 } 1800 }
1798 1801
1799 BoxAllocationSlowPath::Allocate(compiler, this, *cls, temp); 1802 BoxAllocationSlowPath::Allocate(compiler, this, *cls, temp, temp2);
1800 __ movq(temp2, temp); 1803 __ movq(temp2, temp);
1801 __ StoreIntoObject(instance_reg, 1804 __ StoreIntoObject(instance_reg,
1802 FieldAddress(instance_reg, offset_in_bytes_), 1805 FieldAddress(instance_reg, offset_in_bytes_),
1803 temp2); 1806 temp2);
1804 } else { 1807 } else {
1805 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes_)); 1808 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes_));
1806 } 1809 }
1807 switch (cid) { 1810 switch (cid) {
1808 case kDoubleCid: 1811 case kDoubleCid:
1809 __ Comment("UnboxedDoubleStoreInstanceFieldInstr"); 1812 __ Comment("UnboxedDoubleStoreInstanceFieldInstr");
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 intptr_t num_elements, 2044 intptr_t num_elements,
2042 Label* slow_path, 2045 Label* slow_path,
2043 Label* done) { 2046 Label* done) {
2044 const int kInlineArraySize = 12; // Same as kInlineInstanceSize. 2047 const int kInlineArraySize = 12; // Same as kInlineInstanceSize.
2045 const Register kLengthReg = R10; 2048 const Register kLengthReg = R10;
2046 const Register kElemTypeReg = RBX; 2049 const Register kElemTypeReg = RBX;
2047 const intptr_t instance_size = Array::InstanceSize(num_elements); 2050 const intptr_t instance_size = Array::InstanceSize(num_elements);
2048 2051
2049 __ TryAllocateArray(kArrayCid, instance_size, slow_path, Assembler::kFarJump, 2052 __ TryAllocateArray(kArrayCid, instance_size, slow_path, Assembler::kFarJump,
2050 RAX, // instance 2053 RAX, // instance
2051 RCX); // end address 2054 RCX, // end address
2055 R13); // temp
2052 2056
2053 // RAX: new object start as a tagged pointer. 2057 // RAX: new object start as a tagged pointer.
2054 // Store the type argument field. 2058 // Store the type argument field.
2055 __ InitializeFieldNoBarrier(RAX, 2059 __ InitializeFieldNoBarrier(RAX,
2056 FieldAddress(RAX, Array::type_arguments_offset()), 2060 FieldAddress(RAX, Array::type_arguments_offset()),
2057 kElemTypeReg); 2061 kElemTypeReg);
2058 2062
2059 // Set the length field. 2063 // Set the length field.
2060 __ InitializeFieldNoBarrier(RAX, 2064 __ InitializeFieldNoBarrier(RAX,
2061 FieldAddress(RAX, Array::length_offset()), 2065 FieldAddress(RAX, Array::length_offset()),
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 // Fall through. 2221 // Fall through.
2218 __ jmp(&load_pointer); 2222 __ jmp(&load_pointer);
2219 2223
2220 if (!compiler->is_optimizing()) { 2224 if (!compiler->is_optimizing()) {
2221 locs()->live_registers()->Add(locs()->in(0)); 2225 locs()->live_registers()->Add(locs()->in(0));
2222 } 2226 }
2223 2227
2224 { 2228 {
2225 __ Bind(&load_double); 2229 __ Bind(&load_double);
2226 BoxAllocationSlowPath::Allocate( 2230 BoxAllocationSlowPath::Allocate(
2227 compiler, this, compiler->double_class(), result); 2231 compiler, this, compiler->double_class(), result, temp);
2228 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes())); 2232 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes()));
2229 __ movsd(value, FieldAddress(temp, Double::value_offset())); 2233 __ movsd(value, FieldAddress(temp, Double::value_offset()));
2230 __ movsd(FieldAddress(result, Double::value_offset()), value); 2234 __ movsd(FieldAddress(result, Double::value_offset()), value);
2231 __ jmp(&done); 2235 __ jmp(&done);
2232 } 2236 }
2233 2237
2234 { 2238 {
2235 __ Bind(&load_float32x4); 2239 __ Bind(&load_float32x4);
2236 BoxAllocationSlowPath::Allocate( 2240 BoxAllocationSlowPath::Allocate(
2237 compiler, this, compiler->float32x4_class(), result); 2241 compiler, this, compiler->float32x4_class(), result, temp);
2238 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes())); 2242 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes()));
2239 __ movups(value, FieldAddress(temp, Float32x4::value_offset())); 2243 __ movups(value, FieldAddress(temp, Float32x4::value_offset()));
2240 __ movups(FieldAddress(result, Float32x4::value_offset()), value); 2244 __ movups(FieldAddress(result, Float32x4::value_offset()), value);
2241 __ jmp(&done); 2245 __ jmp(&done);
2242 } 2246 }
2243 2247
2244 { 2248 {
2245 __ Bind(&load_float64x2); 2249 __ Bind(&load_float64x2);
2246 BoxAllocationSlowPath::Allocate( 2250 BoxAllocationSlowPath::Allocate(
2247 compiler, this, compiler->float64x2_class(), result); 2251 compiler, this, compiler->float64x2_class(), result, temp);
2248 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes())); 2252 __ movq(temp, FieldAddress(instance_reg, offset_in_bytes()));
2249 __ movups(value, FieldAddress(temp, Float64x2::value_offset())); 2253 __ movups(value, FieldAddress(temp, Float64x2::value_offset()));
2250 __ movups(FieldAddress(result, Float64x2::value_offset()), value); 2254 __ movups(FieldAddress(result, Float64x2::value_offset()), value);
2251 __ jmp(&done); 2255 __ jmp(&done);
2252 } 2256 }
2253 2257
2254 __ Bind(&load_pointer); 2258 __ Bind(&load_pointer);
2255 } 2259 }
2256 __ movq(result, FieldAddress(instance_reg, offset_in_bytes())); 2260 __ movq(result, FieldAddress(instance_reg, offset_in_bytes()));
2257 __ Bind(&done); 2261 __ Bind(&done);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 __ Bind(&type_arguments_instantiated); 2364 __ Bind(&type_arguments_instantiated);
2361 ASSERT(instantiator_reg == result_reg); 2365 ASSERT(instantiator_reg == result_reg);
2362 } 2366 }
2363 2367
2364 2368
2365 LocationSummary* AllocateUninitializedContextInstr::MakeLocationSummary( 2369 LocationSummary* AllocateUninitializedContextInstr::MakeLocationSummary(
2366 Zone* zone, 2370 Zone* zone,
2367 bool opt) const { 2371 bool opt) const {
2368 ASSERT(opt); 2372 ASSERT(opt);
2369 const intptr_t kNumInputs = 0; 2373 const intptr_t kNumInputs = 0;
2370 const intptr_t kNumTemps = 1; 2374 const intptr_t kNumTemps = 2;
2371 LocationSummary* locs = new(zone) LocationSummary( 2375 LocationSummary* locs = new(zone) LocationSummary(
2372 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath); 2376 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
2373 locs->set_temp(0, Location::RegisterLocation(R10)); 2377 locs->set_temp(0, Location::RegisterLocation(R10));
2378 locs->set_temp(1, Location::RegisterLocation(R13));
2374 locs->set_out(0, Location::RegisterLocation(RAX)); 2379 locs->set_out(0, Location::RegisterLocation(RAX));
2375 return locs; 2380 return locs;
2376 } 2381 }
2377 2382
2378 2383
2379 class AllocateContextSlowPath : public SlowPathCode { 2384 class AllocateContextSlowPath : public SlowPathCode {
2380 public: 2385 public:
2381 explicit AllocateContextSlowPath( 2386 explicit AllocateContextSlowPath(
2382 AllocateUninitializedContextInstr* instruction) 2387 AllocateUninitializedContextInstr* instruction)
2383 : instruction_(instruction) { } 2388 : instruction_(instruction) { }
(...skipping 29 matching lines...) Expand all
2413 Register temp = locs()->temp(0).reg(); 2418 Register temp = locs()->temp(0).reg();
2414 Register result = locs()->out(0).reg(); 2419 Register result = locs()->out(0).reg();
2415 // Try allocate the object. 2420 // Try allocate the object.
2416 AllocateContextSlowPath* slow_path = new AllocateContextSlowPath(this); 2421 AllocateContextSlowPath* slow_path = new AllocateContextSlowPath(this);
2417 compiler->AddSlowPathCode(slow_path); 2422 compiler->AddSlowPathCode(slow_path);
2418 intptr_t instance_size = Context::InstanceSize(num_context_variables()); 2423 intptr_t instance_size = Context::InstanceSize(num_context_variables());
2419 2424
2420 __ TryAllocateArray(kContextCid, instance_size, slow_path->entry_label(), 2425 __ TryAllocateArray(kContextCid, instance_size, slow_path->entry_label(),
2421 Assembler::kFarJump, 2426 Assembler::kFarJump,
2422 result, // instance 2427 result, // instance
2423 temp); // end address 2428 temp, // end address
2429 locs()->temp(1).reg());
2424 2430
2425 // Setup up number of context variables field. 2431 // Setup up number of context variables field.
2426 __ movq(FieldAddress(result, Context::num_variables_offset()), 2432 __ movq(FieldAddress(result, Context::num_variables_offset()),
2427 Immediate(num_context_variables())); 2433 Immediate(num_context_variables()));
2428 2434
2429 __ Bind(slow_path->exit_label()); 2435 __ Bind(slow_path->exit_label());
2430 } 2436 }
2431 2437
2432 2438
2433 LocationSummary* AllocateContextInstr::MakeLocationSummary(Zone* zone, 2439 LocationSummary* AllocateContextInstr::MakeLocationSummary(Zone* zone,
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
3254 __ orq(temp, right); 3260 __ orq(temp, right);
3255 __ testq(temp, Immediate(kSmiTagMask)); 3261 __ testq(temp, Immediate(kSmiTagMask));
3256 } 3262 }
3257 __ j(ZERO, deopt); 3263 __ j(ZERO, deopt);
3258 } 3264 }
3259 3265
3260 3266
3261 LocationSummary* BoxInstr::MakeLocationSummary(Zone* zone, 3267 LocationSummary* BoxInstr::MakeLocationSummary(Zone* zone,
3262 bool opt) const { 3268 bool opt) const {
3263 const intptr_t kNumInputs = 1; 3269 const intptr_t kNumInputs = 1;
3264 const intptr_t kNumTemps = 0; 3270 const intptr_t kNumTemps = 1;
3265 LocationSummary* summary = new(zone) LocationSummary( 3271 LocationSummary* summary = new(zone) LocationSummary(
3266 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath); 3272 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
3267 summary->set_in(0, Location::RequiresFpuRegister()); 3273 summary->set_in(0, Location::RequiresFpuRegister());
3274 summary->set_temp(0, Location::RequiresRegister());
3268 summary->set_out(0, Location::RequiresRegister()); 3275 summary->set_out(0, Location::RequiresRegister());
3269 return summary; 3276 return summary;
3270 } 3277 }
3271 3278
3272 3279
3273 void BoxInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3280 void BoxInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3274 Register out_reg = locs()->out(0).reg(); 3281 Register out_reg = locs()->out(0).reg();
3282 Register temp = locs()->temp(0).reg();
3275 XmmRegister value = locs()->in(0).fpu_reg(); 3283 XmmRegister value = locs()->in(0).fpu_reg();
3276 3284
3277 BoxAllocationSlowPath::Allocate( 3285 BoxAllocationSlowPath::Allocate(
3278 compiler, this, compiler->BoxClassFor(from_representation()), out_reg); 3286 compiler, this, compiler->BoxClassFor(from_representation()), out_reg,
3287 temp);
3279 __ movsd(FieldAddress(out_reg, Double::value_offset()), value); 3288 __ movsd(FieldAddress(out_reg, Double::value_offset()), value);
3280 switch (from_representation()) { 3289 switch (from_representation()) {
3281 case kUnboxedDouble: 3290 case kUnboxedDouble:
3282 __ movsd(FieldAddress(out_reg, ValueOffset()), value); 3291 __ movsd(FieldAddress(out_reg, ValueOffset()), value);
3283 break; 3292 break;
3284 case kUnboxedFloat32x4: 3293 case kUnboxedFloat32x4:
3285 case kUnboxedFloat64x2: 3294 case kUnboxedFloat64x2:
3286 case kUnboxedInt32x4: 3295 case kUnboxedInt32x4:
3287 __ movups(FieldAddress(out_reg, ValueOffset()), value); 3296 __ movups(FieldAddress(out_reg, ValueOffset()), value);
3288 break; 3297 break;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
3497 ASSERT(from_representation() == kUnboxedUint32); 3506 ASSERT(from_representation() == kUnboxedUint32);
3498 __ movl(out, value); 3507 __ movl(out, value);
3499 } 3508 }
3500 __ SmiTag(out); 3509 __ SmiTag(out);
3501 } 3510 }
3502 3511
3503 3512
3504 LocationSummary* BoxInt64Instr::MakeLocationSummary(Zone* zone, 3513 LocationSummary* BoxInt64Instr::MakeLocationSummary(Zone* zone,
3505 bool opt) const { 3514 bool opt) const {
3506 const intptr_t kNumInputs = 1; 3515 const intptr_t kNumInputs = 1;
3507 const intptr_t kNumTemps = 0; 3516 const intptr_t kNumTemps = ValueFitsSmi() ? 0 : 1;
3508 LocationSummary* summary = new(zone) LocationSummary( 3517 LocationSummary* summary = new(zone) LocationSummary(
3509 zone, 3518 zone,
3510 kNumInputs, 3519 kNumInputs,
3511 kNumTemps, 3520 kNumTemps,
3512 ValueFitsSmi() ? LocationSummary::kNoCall 3521 ValueFitsSmi() ? LocationSummary::kNoCall
3513 : LocationSummary::kCallOnSlowPath); 3522 : LocationSummary::kCallOnSlowPath);
3514 summary->set_in(0, Location::RequiresRegister()); 3523 summary->set_in(0, Location::RequiresRegister());
3524 if (!ValueFitsSmi()) {
3525 summary->set_temp(0, Location::RequiresRegister());
3526 }
3515 summary->set_out(0, Location::RequiresRegister()); 3527 summary->set_out(0, Location::RequiresRegister());
3516 return summary; 3528 return summary;
3517 } 3529 }
3518 3530
3519 3531
3520 void BoxInt64Instr::EmitNativeCode(FlowGraphCompiler* compiler) { 3532 void BoxInt64Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
3521 const Register out = locs()->out(0).reg(); 3533 const Register out = locs()->out(0).reg();
3522 const Register value = locs()->in(0).reg(); 3534 const Register value = locs()->in(0).reg();
3523 __ MoveRegister(out, value); 3535 __ MoveRegister(out, value);
3524 __ SmiTag(out); 3536 __ SmiTag(out);
3525 if (!ValueFitsSmi()) { 3537 if (!ValueFitsSmi()) {
3538 const Register temp = locs()->temp(0).reg();
3526 Label done; 3539 Label done;
3527 __ j(NO_OVERFLOW, &done); 3540 __ j(NO_OVERFLOW, &done);
3528 BoxAllocationSlowPath::Allocate( 3541 BoxAllocationSlowPath::Allocate(
3529 compiler, this, compiler->mint_class(), out); 3542 compiler, this, compiler->mint_class(), out, temp);
3530 __ movq(FieldAddress(out, Mint::value_offset()), value); 3543 __ movq(FieldAddress(out, Mint::value_offset()), value);
3531 __ Bind(&done); 3544 __ Bind(&done);
3532 } 3545 }
3533 } 3546 }
3534 3547
3535 3548
3536 LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary(Zone* zone, 3549 LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary(Zone* zone,
3537 bool opt) const { 3550 bool opt) const {
3538 const intptr_t kNumInputs = 2; 3551 const intptr_t kNumInputs = 2;
3539 const intptr_t kNumTemps = 0; 3552 const intptr_t kNumTemps = 0;
(...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after
6420 __ Drop(1); 6433 __ Drop(1);
6421 __ popq(result); 6434 __ popq(result);
6422 } 6435 }
6423 6436
6424 6437
6425 } // namespace dart 6438 } // namespace dart
6426 6439
6427 #undef __ 6440 #undef __
6428 6441
6429 #endif // defined TARGET_ARCH_X64 6442 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698