| OLD | NEW |
| 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 5269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5280 summary->set_temp(0, Location::RequiresRegister()); | 5280 summary->set_temp(0, Location::RequiresRegister()); |
| 5281 if (need_mask_temp) { | 5281 if (need_mask_temp) { |
| 5282 summary->set_temp(1, Location::RequiresRegister()); | 5282 summary->set_temp(1, Location::RequiresRegister()); |
| 5283 } | 5283 } |
| 5284 } | 5284 } |
| 5285 return summary; | 5285 return summary; |
| 5286 } | 5286 } |
| 5287 | 5287 |
| 5288 | 5288 |
| 5289 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5289 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 5290 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ? | 5290 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
| 5291 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass; | 5291 ICData::kDeoptCheckClass, |
| 5292 licm_hoisted_ ? ICData::kHoisted : 0); |
| 5292 if (IsNullCheck()) { | 5293 if (IsNullCheck()) { |
| 5293 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason); | |
| 5294 __ CompareObject(locs()->in(0).reg(), | 5294 __ CompareObject(locs()->in(0).reg(), |
| 5295 Object::null_object(), PP); | 5295 Object::null_object(), PP); |
| 5296 __ j(EQUAL, deopt); | 5296 __ j(EQUAL, deopt); |
| 5297 return; | 5297 return; |
| 5298 } | 5298 } |
| 5299 | 5299 |
| 5300 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || | 5300 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || |
| 5301 (unary_checks().NumberOfChecks() > 1)); | 5301 (unary_checks().NumberOfChecks() > 1)); |
| 5302 Register value = locs()->in(0).reg(); | 5302 Register value = locs()->in(0).reg(); |
| 5303 Register temp = locs()->temp(0).reg(); | 5303 Register temp = locs()->temp(0).reg(); |
| 5304 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason); | |
| 5305 Label is_ok; | 5304 Label is_ok; |
| 5306 intptr_t cix = 0; | 5305 intptr_t cix = 0; |
| 5307 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { | 5306 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { |
| 5308 __ testq(value, Immediate(kSmiTagMask)); | 5307 __ testq(value, Immediate(kSmiTagMask)); |
| 5309 __ j(ZERO, &is_ok); | 5308 __ j(ZERO, &is_ok); |
| 5310 cix++; // Skip first check. | 5309 cix++; // Skip first check. |
| 5311 } else { | 5310 } else { |
| 5312 __ testq(value, Immediate(kSmiTagMask)); | 5311 __ testq(value, Immediate(kSmiTagMask)); |
| 5313 __ j(ZERO, deopt); | 5312 __ j(ZERO, deopt); |
| 5314 } | 5313 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5394 const intptr_t kNumTemps = 0; | 5393 const intptr_t kNumTemps = 0; |
| 5395 LocationSummary* locs = new(isolate) LocationSummary( | 5394 LocationSummary* locs = new(isolate) LocationSummary( |
| 5396 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5395 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 5397 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); | 5396 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); |
| 5398 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); | 5397 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); |
| 5399 return locs; | 5398 return locs; |
| 5400 } | 5399 } |
| 5401 | 5400 |
| 5402 | 5401 |
| 5403 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5402 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 5404 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 5403 Label* deopt = compiler->AddDeoptStub( |
| 5405 ICData::kDeoptCheckArrayBound); | 5404 deopt_id(), |
| 5405 ICData::kDeoptCheckArrayBound, |
| 5406 generalized_ ? ICData::kGeneralized : 0); |
| 5406 | 5407 |
| 5407 Location length_loc = locs()->in(kLengthPos); | 5408 Location length_loc = locs()->in(kLengthPos); |
| 5408 Location index_loc = locs()->in(kIndexPos); | 5409 Location index_loc = locs()->in(kIndexPos); |
| 5409 | 5410 |
| 5410 if (length_loc.IsConstant() && index_loc.IsConstant()) { | 5411 if (length_loc.IsConstant() && index_loc.IsConstant()) { |
| 5411 ASSERT((Smi::Cast(length_loc.constant()).Value() <= | 5412 ASSERT((Smi::Cast(length_loc.constant()).Value() <= |
| 5412 Smi::Cast(index_loc.constant()).Value()) || | 5413 Smi::Cast(index_loc.constant()).Value()) || |
| 5413 (Smi::Cast(index_loc.constant()).Value() < 0)); | 5414 (Smi::Cast(index_loc.constant()).Value() < 0)); |
| 5414 // Unconditionally deoptimize for constant bounds checks because they | 5415 // Unconditionally deoptimize for constant bounds checks because they |
| 5415 // only occur only when index is out-of-bounds. | 5416 // only occur only when index is out-of-bounds. |
| 5416 __ jmp(deopt); | 5417 __ jmp(deopt); |
| 5417 return; | 5418 return; |
| 5418 } | 5419 } |
| 5419 | 5420 |
| 5420 if (index_loc.IsConstant()) { | 5421 if (index_loc.IsConstant()) { |
| 5421 Register length = length_loc.reg(); | 5422 Register length = length_loc.reg(); |
| 5422 const Smi& index = Smi::Cast(index_loc.constant()); | 5423 const Smi& index = Smi::Cast(index_loc.constant()); |
| 5423 __ CompareImmediate( | 5424 __ CompareImmediate( |
| 5424 length, Immediate(reinterpret_cast<int64_t>(index.raw())), PP); | 5425 length, Immediate(reinterpret_cast<int64_t>(index.raw())), PP); |
| 5425 __ j(BELOW_EQUAL, deopt); | 5426 __ j(BELOW_EQUAL, deopt); |
| 5426 } else if (length_loc.IsConstant()) { | 5427 } else if (length_loc.IsConstant()) { |
| 5427 const Smi& length = Smi::Cast(length_loc.constant()); | 5428 const Smi& length = Smi::Cast(length_loc.constant()); |
| 5428 Register index = index_loc.reg(); | 5429 Register index = index_loc.reg(); |
| 5429 __ CompareImmediate( | 5430 if (length.Value() == Smi::kMaxValue) { |
| 5430 index, Immediate(reinterpret_cast<int64_t>(length.raw())), PP); | 5431 __ testq(index, index); |
| 5431 __ j(ABOVE_EQUAL, deopt); | 5432 __ j(NEGATIVE, deopt); |
| 5433 } else { |
| 5434 __ CompareImmediate( |
| 5435 index, Immediate(reinterpret_cast<int64_t>(length.raw())), PP); |
| 5436 __ j(ABOVE_EQUAL, deopt); |
| 5437 } |
| 5432 } else { | 5438 } else { |
| 5433 Register length = length_loc.reg(); | 5439 Register length = length_loc.reg(); |
| 5434 Register index = index_loc.reg(); | 5440 Register index = index_loc.reg(); |
| 5435 __ cmpq(index, length); | 5441 __ cmpq(index, length); |
| 5436 __ j(ABOVE_EQUAL, deopt); | 5442 __ j(ABOVE_EQUAL, deopt); |
| 5437 } | 5443 } |
| 5438 } | 5444 } |
| 5439 | 5445 |
| 5440 | 5446 |
| 5441 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(Isolate* isolate, | 5447 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(Isolate* isolate, |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5913 __ movq(R10, Immediate(kInvalidObjectPointer)); | 5919 __ movq(R10, Immediate(kInvalidObjectPointer)); |
| 5914 __ movq(RBX, Immediate(kInvalidObjectPointer)); | 5920 __ movq(RBX, Immediate(kInvalidObjectPointer)); |
| 5915 #endif | 5921 #endif |
| 5916 } | 5922 } |
| 5917 | 5923 |
| 5918 } // namespace dart | 5924 } // namespace dart |
| 5919 | 5925 |
| 5920 #undef __ | 5926 #undef __ |
| 5921 | 5927 |
| 5922 #endif // defined TARGET_ARCH_X64 | 5928 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |