| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 const Immediate raw_null = | 348 const Immediate raw_null = |
| 349 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 349 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 350 Label check_identity; | 350 Label check_identity; |
| 351 __ cmpq(Address(RSP, 0 * kWordSize), raw_null); | 351 __ cmpq(Address(RSP, 0 * kWordSize), raw_null); |
| 352 __ j(EQUAL, &check_identity, Assembler::kNearJump); | 352 __ j(EQUAL, &check_identity, Assembler::kNearJump); |
| 353 __ cmpq(Address(RSP, 1 * kWordSize), raw_null); | 353 __ cmpq(Address(RSP, 1 * kWordSize), raw_null); |
| 354 __ j(EQUAL, &check_identity, Assembler::kNearJump); | 354 __ j(EQUAL, &check_identity, Assembler::kNearJump); |
| 355 | 355 |
| 356 ICData& equality_ic_data = ICData::ZoneHandle(original_ic_data.raw()); | 356 ICData& equality_ic_data = ICData::ZoneHandle(original_ic_data.raw()); |
| 357 if (equality_ic_data.IsNull()) { | 357 if (compiler->is_optimizing()) { |
| 358 ASSERT(!original_ic_data.IsNull()); |
| 359 equality_ic_data = original_ic_data.AsUnaryClassChecks(); |
| 360 } else { |
| 358 equality_ic_data = ICData::New(compiler->parsed_function().function(), | 361 equality_ic_data = ICData::New(compiler->parsed_function().function(), |
| 359 operator_name, | 362 operator_name, |
| 360 deopt_id, | 363 deopt_id, |
| 361 kNumArgumentsChecked); | 364 kNumArgumentsChecked); |
| 362 } | 365 } |
| 363 compiler->GenerateInstanceCall(deopt_id, | 366 compiler->GenerateInstanceCall(deopt_id, |
| 364 token_pos, | 367 token_pos, |
| 365 kNumberOfArguments, | 368 kNumberOfArguments, |
| 366 kNoArgumentNames, | 369 kNoArgumentNames, |
| 367 locs, | 370 locs, |
| 368 equality_ic_data); | 371 equality_ic_data); |
| 369 Label check_ne; | 372 Label check_ne; |
| 370 __ jmp(&check_ne); | 373 __ jmp(&check_ne); |
| 371 | 374 |
| 372 __ Bind(&check_identity); | 375 __ Bind(&check_identity); |
| 373 // Call stub, load IC data in register. The stub will update ICData if | 376 Label equality_done; |
| 374 // necessary. | 377 if (compiler->is_optimizing()) { |
| 375 Register ic_data_reg = locs->temp(0).reg(); | 378 // No need to update IC data. |
| 376 ASSERT(ic_data_reg == RBX); // Stub depends on it. | 379 Label is_true; |
| 377 __ LoadObject(ic_data_reg, equality_ic_data); | 380 __ popq(RAX); |
| 378 compiler->GenerateCall(token_pos, | 381 __ popq(RDX); |
| 379 &StubCode::EqualityWithNullArgLabel(), | 382 __ cmpq(RAX, RDX); |
| 380 PcDescriptors::kOther, | 383 __ j(EQUAL, &is_true); |
| 381 locs); | 384 __ LoadObject(RAX, (kind == Token::kEQ) ? compiler->bool_false() |
| 382 __ Drop(2); | 385 : compiler->bool_true()); |
| 386 __ jmp(&equality_done); |
| 387 __ Bind(&is_true); |
| 388 __ LoadObject(RAX, (kind == Token::kEQ) ? compiler->bool_true() |
| 389 : compiler->bool_false()); |
| 390 if (kind == Token::kNE) { |
| 391 // Skip not-equal result conversion. |
| 392 __ jmp(&equality_done); |
| 393 } |
| 394 } else { |
| 395 // Call stub, load IC data in register. The stub will update ICData if |
| 396 // necessary. |
| 397 Register ic_data_reg = locs->temp(0).reg(); |
| 398 ASSERT(ic_data_reg == RBX); // Stub depends on it. |
| 399 __ LoadObject(ic_data_reg, equality_ic_data); |
| 400 compiler->GenerateCall(token_pos, |
| 401 &StubCode::EqualityWithNullArgLabel(), |
| 402 PcDescriptors::kOther, |
| 403 locs); |
| 404 __ Drop(2); |
| 405 } |
| 383 __ Bind(&check_ne); | 406 __ Bind(&check_ne); |
| 384 if (kind == Token::kNE) { | 407 if (kind == Token::kNE) { |
| 385 Label false_label, true_label, done; | 408 Label false_label, true_label, done; |
| 386 // Negate the condition: true label returns false and vice versa. | 409 // Negate the condition: true label returns false and vice versa. |
| 387 __ CompareObject(RAX, compiler->bool_true()); | 410 __ CompareObject(RAX, compiler->bool_true()); |
| 388 __ j(EQUAL, &true_label, Assembler::kNearJump); | 411 __ j(EQUAL, &true_label, Assembler::kNearJump); |
| 389 __ Bind(&false_label); | 412 __ Bind(&false_label); |
| 390 __ LoadObject(RAX, compiler->bool_true()); | 413 __ LoadObject(RAX, compiler->bool_true()); |
| 391 __ jmp(&done, Assembler::kNearJump); | 414 __ jmp(&done, Assembler::kNearJump); |
| 392 __ Bind(&true_label); | 415 __ Bind(&true_label); |
| 393 __ LoadObject(RAX, compiler->bool_false()); | 416 __ LoadObject(RAX, compiler->bool_false()); |
| 394 __ Bind(&done); | 417 __ Bind(&done); |
| 395 } | 418 } |
| 419 __ Bind(&equality_done); |
| 396 } | 420 } |
| 397 | 421 |
| 398 | 422 |
| 399 static void EmitEqualityAsPolymorphicCall(FlowGraphCompiler* compiler, | 423 static void EmitEqualityAsPolymorphicCall(FlowGraphCompiler* compiler, |
| 400 const ICData& orig_ic_data, | 424 const ICData& orig_ic_data, |
| 401 LocationSummary* locs, | 425 LocationSummary* locs, |
| 402 BranchInstr* branch, | 426 BranchInstr* branch, |
| 403 Token::Kind kind, | 427 Token::Kind kind, |
| 404 intptr_t deopt_id, | 428 intptr_t deopt_id, |
| 405 intptr_t token_pos) { | 429 intptr_t token_pos) { |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 const String& function_name = | 858 const String& function_name = |
| 835 String::ZoneHandle(Symbols::New(Token::Str(kind()))); | 859 String::ZoneHandle(Symbols::New(Token::Str(kind()))); |
| 836 if (!compiler->is_optimizing()) { | 860 if (!compiler->is_optimizing()) { |
| 837 compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore, | 861 compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore, |
| 838 deopt_id(), | 862 deopt_id(), |
| 839 token_pos()); | 863 token_pos()); |
| 840 } | 864 } |
| 841 const intptr_t kNumArguments = 2; | 865 const intptr_t kNumArguments = 2; |
| 842 const intptr_t kNumArgsChecked = 2; // Type-feedback. | 866 const intptr_t kNumArgsChecked = 2; // Type-feedback. |
| 843 ICData& relational_ic_data = ICData::ZoneHandle(ic_data()->raw()); | 867 ICData& relational_ic_data = ICData::ZoneHandle(ic_data()->raw()); |
| 844 if (relational_ic_data.IsNull()) { | 868 if (compiler->is_optimizing()) { |
| 869 ASSERT(!ic_data()->IsNull()); |
| 870 relational_ic_data = ic_data()->AsUnaryClassChecks(); |
| 871 } else { |
| 845 relational_ic_data = ICData::New(compiler->parsed_function().function(), | 872 relational_ic_data = ICData::New(compiler->parsed_function().function(), |
| 846 function_name, | 873 function_name, |
| 847 deopt_id(), | 874 deopt_id(), |
| 848 kNumArgsChecked); | 875 kNumArgsChecked); |
| 849 } | 876 } |
| 850 compiler->GenerateInstanceCall(deopt_id(), | 877 compiler->GenerateInstanceCall(deopt_id(), |
| 851 token_pos(), | 878 token_pos(), |
| 852 kNumArguments, | 879 kNumArguments, |
| 853 Array::ZoneHandle(), // No optional arguments. | 880 Array::ZoneHandle(), // No optional arguments. |
| 854 locs(), | 881 locs(), |
| (...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 | 2331 |
| 2305 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2332 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2306 UNIMPLEMENTED(); | 2333 UNIMPLEMENTED(); |
| 2307 } | 2334 } |
| 2308 | 2335 |
| 2309 } // namespace dart | 2336 } // namespace dart |
| 2310 | 2337 |
| 2311 #undef __ | 2338 #undef __ |
| 2312 | 2339 |
| 2313 #endif // defined TARGET_ARCH_X64 | 2340 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |