Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_c_function()))); | 270 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_c_function()))); |
| 271 __ movq(R10, Immediate(argument_count())); | 271 __ movq(R10, Immediate(argument_count())); |
| 272 compiler->GenerateCall(token_index(), | 272 compiler->GenerateCall(token_index(), |
| 273 try_index(), | 273 try_index(), |
| 274 &StubCode::CallNativeCFunctionLabel(), | 274 &StubCode::CallNativeCFunctionLabel(), |
| 275 PcDescriptors::kOther); | 275 PcDescriptors::kOther); |
| 276 __ popq(result); | 276 __ popq(result); |
| 277 } | 277 } |
| 278 | 278 |
| 279 | 279 |
| 280 LocationSummary* LoadIndexedComp::MakeLocationSummary() const { | |
| 281 const intptr_t kNumInputs = 2; | |
| 282 if (receiver_type() == kGrowableObjectArray) { | |
| 283 const intptr_t kNumTemps = 1; | |
| 284 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); | |
| 285 locs->set_in(0, Location::RequiresRegister()); | |
| 286 locs->set_in(1, Location::RequiresRegister()); | |
| 287 locs->set_temp(0, Location::RequiresRegister()); | |
| 288 locs->set_out(Location::RequiresRegister()); | |
| 289 return locs; | |
| 290 } else if (receiver_type() == kArray || receiver_type() == kImmutableArray) { | |
| 291 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); | |
| 292 } else { | |
| 293 ASSERT(receiver_type() == kIllegalObjectKind); | |
| 294 return MakeCallSummary(); | |
| 295 } | |
| 296 } | |
| 297 | |
| 298 | |
| 299 static void EmitLoadIndexedGeneric(FlowGraphCompiler* compiler, | |
| 300 LoadIndexedComp* comp) { | |
| 301 const String& function_name = | |
| 302 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX))); | |
| 303 | |
| 304 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | |
| 305 comp->cid(), | |
| 306 comp->token_index(), | |
| 307 comp->try_index()); | |
| 308 | |
| 309 const intptr_t kNumArguments = 2; | |
| 310 const intptr_t kNumArgsChecked = 1; // Type-feedback. | |
| 311 compiler->GenerateInstanceCall(comp->cid(), | |
| 312 comp->token_index(), | |
| 313 comp->try_index(), | |
| 314 function_name, | |
| 315 kNumArguments, | |
| 316 Array::ZoneHandle(), // No optional arguments. | |
| 317 kNumArgsChecked); | |
| 318 ASSERT(comp->locs()->out().reg() == RAX); | |
| 319 } | |
| 320 | |
| 321 | |
| 322 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 323 if (receiver_type() == kIllegalObjectKind) { | |
| 324 EmitLoadIndexedGeneric(compiler, this); | |
| 325 return; | |
| 326 } | |
| 327 | |
| 328 Register receiver = locs()->in(0).reg(); | |
| 329 Register index = locs()->in(1).reg(); | |
| 330 Register result = locs()->out().reg(); | |
| 331 | |
| 332 const Class& receiver_class = | |
| 333 Class::ZoneHandle(Isolate::Current()->class_table()->At( | |
| 334 receiver_type())); | |
|
srdjan
2012/06/08 19:16:08
indent should be 4 spaces at each new line.
Vyacheslav Egorov (Google)
2012/06/08 19:23:33
Done.
| |
| 335 | |
| 336 const DeoptReasonId deopt_reason = (receiver_type() == kGrowableObjectArray) ? | |
| 337 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | |
| 338 | |
| 339 Label* deopt = compiler->AddDeoptStub(cid(), | |
| 340 token_index(), | |
| 341 try_index(), | |
| 342 deopt_reason, | |
| 343 receiver, | |
| 344 index); | |
| 345 | |
| 346 __ testq(receiver, Immediate(kSmiTagMask)); // Deoptimize if Smi. | |
| 347 __ j(ZERO, deopt); | |
| 348 __ CompareClassId(receiver, receiver_class.id()); | |
| 349 __ j(NOT_EQUAL, deopt); | |
| 350 | |
| 351 __ testq(index, Immediate(kSmiTagMask)); | |
| 352 __ j(NOT_ZERO, deopt); | |
| 353 | |
| 354 switch (receiver_type()) { | |
| 355 case kArray: | |
| 356 case kImmutableArray: | |
| 357 __ cmpq(index, FieldAddress(receiver, Array::length_offset())); | |
| 358 __ j(ABOVE_EQUAL, deopt); | |
| 359 // Note that index is Smi, i.e, times 4. | |
| 360 ASSERT(kSmiTagShift == 1); | |
| 361 __ movq(result, FieldAddress(receiver, index, TIMES_4, sizeof(RawArray))); | |
| 362 break; | |
| 363 | |
| 364 case kGrowableObjectArray: { | |
| 365 Register temp = locs()->temp(0).reg(); | |
| 366 | |
| 367 __ cmpq(index, | |
| 368 FieldAddress(receiver, GrowableObjectArray::length_offset())); | |
| 369 __ j(ABOVE_EQUAL, deopt); | |
| 370 __ movq(temp, FieldAddress(receiver, GrowableObjectArray::data_offset())); | |
| 371 // Note that index is Smi, i.e, times 4. | |
| 372 ASSERT(kSmiTagShift == 1); | |
| 373 __ movq(result, FieldAddress(temp, index, TIMES_4, sizeof(RawArray))); | |
| 374 break; | |
| 375 } | |
| 376 | |
| 377 default: | |
| 378 UNREACHABLE(); | |
| 379 break; | |
| 380 } | |
| 381 } | |
| 382 | |
| 383 | |
| 280 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { | 384 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { |
| 281 const intptr_t kNumInputs = 3; | 385 const intptr_t kNumInputs = 3; |
| 282 return LocationSummary::Make(kNumInputs, Location::NoLocation()); | 386 return LocationSummary::Make(kNumInputs, Location::NoLocation()); |
| 283 } | 387 } |
| 284 | 388 |
| 285 | 389 |
| 286 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 390 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 287 Register receiver = locs()->in(0).reg(); | 391 Register receiver = locs()->in(0).reg(); |
| 288 Register index = locs()->in(1).reg(); | 392 Register index = locs()->in(1).reg(); |
| 289 Register value = locs()->in(2).reg(); | 393 Register value = locs()->in(2).reg(); |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 } else { | 1223 } else { |
| 1120 UNREACHABLE(); | 1224 UNREACHABLE(); |
| 1121 } | 1225 } |
| 1122 } | 1226 } |
| 1123 | 1227 |
| 1124 } // namespace dart | 1228 } // namespace dart |
| 1125 | 1229 |
| 1126 #undef __ | 1230 #undef __ |
| 1127 | 1231 |
| 1128 #endif // defined TARGET_ARCH_X64 | 1232 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |