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/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
9 | 9 |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 __ movq(RAX, Address(RSP, + 2 * kWordSize)); | 356 __ movq(RAX, Address(RSP, + 2 * kWordSize)); |
357 __ movq(RBX, Address(RSP, + 1 * kWordSize)); | 357 __ movq(RBX, Address(RSP, + 1 * kWordSize)); |
358 __ StoreIntoObject(RAX, | 358 __ StoreIntoObject(RAX, |
359 FieldAddress(RAX, GrowableObjectArray::data_offset()), | 359 FieldAddress(RAX, GrowableObjectArray::data_offset()), |
360 RBX); | 360 RBX); |
361 __ ret(); | 361 __ ret(); |
362 return true; | 362 return true; |
363 } | 363 } |
364 | 364 |
365 | 365 |
| 366 // Add an element to growable array if it doesn't need to grow, otherwise |
| 367 // call into regular code. |
| 368 // On stack: growable array (+2), value (+1), return-address (+0). |
| 369 bool Intrinsifier::GrowableArray_add(Assembler* assembler) { |
| 370 // In checked mode we need to check the incoming argument. |
| 371 if (FLAG_enable_type_checks) return false; |
| 372 Label fall_through; |
| 373 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // Array. |
| 374 __ movq(RCX, FieldAddress(RAX, GrowableObjectArray::length_offset())); |
| 375 // RCX: length. |
| 376 __ movq(RDX, FieldAddress(RAX, GrowableObjectArray::data_offset())); |
| 377 // RDX: data. |
| 378 // Compare length with capacity. |
| 379 __ cmpq(RCX, FieldAddress(RDX, GrowableObjectArray::length_offset())); |
| 380 __ j(EQUAL, &fall_through, Assembler::kNearJump); // Must grow data. |
| 381 const Immediate value_one = Immediate(reinterpret_cast<int64_t>(Smi::New(1))); |
| 382 // len = len + 1; |
| 383 __ addq(FieldAddress(RAX, GrowableObjectArray::length_offset()), value_one); |
| 384 __ movq(RAX, Address(RSP, + 1 * kWordSize)); // Value |
| 385 ASSERT(kSmiTagShift == 1); |
| 386 __ StoreIntoObject(RDX, |
| 387 FieldAddress(RDX, RCX, TIMES_4, sizeof(RawArray)), |
| 388 RAX); |
| 389 __ ret(); |
| 390 __ Bind(&fall_through); |
| 391 return false; |
| 392 } |
| 393 |
| 394 |
366 bool Intrinsifier::ByteArrayBase_getLength(Assembler* assembler) { | 395 bool Intrinsifier::ByteArrayBase_getLength(Assembler* assembler) { |
367 __ movq(RAX, Address(RSP, + 1 * kWordSize)); | 396 __ movq(RAX, Address(RSP, + 1 * kWordSize)); |
368 __ movq(RAX, FieldAddress(RAX, ByteArray::length_offset())); | 397 __ movq(RAX, FieldAddress(RAX, ByteArray::length_offset())); |
369 __ ret(); | 398 __ ret(); |
370 // Generate enough code to satisfy patchability constraint. | 399 // Generate enough code to satisfy patchability constraint. |
371 intptr_t offset = __ CodeSize(); | 400 intptr_t offset = __ CodeSize(); |
372 __ nop(JumpPattern::InstructionLength() - offset); | 401 __ nop(JumpPattern::InstructionLength() - offset); |
373 return true; | 402 return true; |
374 } | 403 } |
375 | 404 |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 __ LoadObject(RAX, bool_true); | 1349 __ LoadObject(RAX, bool_true); |
1321 __ ret(); | 1350 __ ret(); |
1322 return true; | 1351 return true; |
1323 } | 1352 } |
1324 | 1353 |
1325 #undef __ | 1354 #undef __ |
1326 | 1355 |
1327 } // namespace dart | 1356 } // namespace dart |
1328 | 1357 |
1329 #endif // defined TARGET_ARCH_X64 | 1358 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |