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 // The intrinsic code below is executed before a method has built its frame. | 5 // The intrinsic code below is executed before a method has built its frame. |
6 // The return address is on the stack and the arguments below it. | 6 // The return address is on the stack and the arguments below it. |
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. | 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. |
8 // Each intrinsification method returns true if the corresponding | 8 // Each intrinsification method returns true if the corresponding |
9 // Dart method was intrinsified. | 9 // Dart method was intrinsified. |
10 | 10 |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 __ movl(EAX, Address(ESP, + 2 * kWordSize)); | 415 __ movl(EAX, Address(ESP, + 2 * kWordSize)); |
416 __ movl(EBX, Address(ESP, + 1 * kWordSize)); | 416 __ movl(EBX, Address(ESP, + 1 * kWordSize)); |
417 __ StoreIntoObject(EAX, | 417 __ StoreIntoObject(EAX, |
418 FieldAddress(EAX, GrowableObjectArray::data_offset()), | 418 FieldAddress(EAX, GrowableObjectArray::data_offset()), |
419 EBX); | 419 EBX); |
420 __ ret(); | 420 __ ret(); |
421 return true; | 421 return true; |
422 } | 422 } |
423 | 423 |
424 | 424 |
| 425 // Add an element to growable array if it doesn't need to grow, otherwise |
| 426 // call into regular code. |
| 427 // On stack: growable array (+2), value (+1), return-address (+0). |
| 428 bool Intrinsifier::GrowableArray_add(Assembler* assembler) { |
| 429 // In checked mode we need to check the incoming argument. |
| 430 if (FLAG_enable_type_checks) return false; |
| 431 Label fall_through; |
| 432 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array. |
| 433 __ movl(EBX, FieldAddress(EAX, GrowableObjectArray::length_offset())); |
| 434 // EBX: length. |
| 435 __ movl(EDI, FieldAddress(EAX, GrowableObjectArray::data_offset())); |
| 436 // EDI: data. |
| 437 // Compare length with capacity. |
| 438 __ cmpl(EBX, FieldAddress(EDI, GrowableObjectArray::length_offset())); |
| 439 __ j(EQUAL, &fall_through, Assembler::kNearJump); // Must grow data. |
| 440 const Immediate value_one = Immediate(reinterpret_cast<int32_t>(Smi::New(1))); |
| 441 // len = len + 1; |
| 442 __ addl(FieldAddress(EAX, GrowableObjectArray::length_offset()), value_one); |
| 443 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Value |
| 444 ASSERT(kSmiTagShift == 1); |
| 445 __ StoreIntoObject(EDI, |
| 446 FieldAddress(EDI, EBX, TIMES_2, sizeof(RawArray)), |
| 447 EAX); |
| 448 __ ret(); |
| 449 __ Bind(&fall_through); |
| 450 return false; |
| 451 } |
| 452 |
| 453 |
425 // Gets the length of a ByteArray. | 454 // Gets the length of a ByteArray. |
426 bool Intrinsifier::ByteArrayBase_getLength(Assembler* assembler) { | 455 bool Intrinsifier::ByteArrayBase_getLength(Assembler* assembler) { |
427 __ movl(EAX, Address(ESP, + 1 * kWordSize)); | 456 __ movl(EAX, Address(ESP, + 1 * kWordSize)); |
428 __ movl(EAX, FieldAddress(EAX, ByteArray::length_offset())); | 457 __ movl(EAX, FieldAddress(EAX, ByteArray::length_offset())); |
429 __ ret(); | 458 __ ret(); |
430 return true; | 459 return true; |
431 } | 460 } |
432 | 461 |
433 | 462 |
434 // Assumes the first argument is a byte array, tests if the second | 463 // Assumes the first argument is a byte array, tests if the second |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 __ Bind(&is_true); | 1393 __ Bind(&is_true); |
1365 __ LoadObject(EAX, bool_true); | 1394 __ LoadObject(EAX, bool_true); |
1366 __ ret(); | 1395 __ ret(); |
1367 return true; | 1396 return true; |
1368 } | 1397 } |
1369 | 1398 |
1370 #undef __ | 1399 #undef __ |
1371 } // namespace dart | 1400 } // namespace dart |
1372 | 1401 |
1373 #endif // defined TARGET_ARCH_IA32 | 1402 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |