Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(860)

Side by Side Diff: runtime/vm/intrinsifier_ia32.cc

Issue 9958046: Implement {Int,Uint}{8,16,32,64} and Float{32,64} typed arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add view classes and their tests Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
12 #if defined(TARGET_ARCH_IA32) 12 #if defined(TARGET_ARCH_IA32)
13 13
14 #include "vm/intrinsifier.h" 14 #include "vm/intrinsifier.h"
15 15
16 #include "vm/assembler.h" 16 #include "vm/assembler.h"
17 #include "vm/assembler_macros.h" 17 #include "vm/assembler_macros.h"
18 #include "vm/object.h" 18 #include "vm/object.h"
19 #include "vm/object_store.h" 19 #include "vm/object_store.h"
20 #include "vm/os.h" 20 #include "vm/os.h"
21 #include "vm/stub_code.h" 21 #include "vm/stub_code.h"
22 22
23 namespace dart { 23 namespace dart {
24 24
25 DECLARE_FLAG(bool, enable_type_checks); 25 DECLARE_FLAG(bool, enable_type_checks);
26 26
27
28 #define __ assembler-> 27 #define __ assembler->
29 28
30 bool Intrinsifier::ObjectArray_Allocate(Assembler* assembler) { 29 bool Intrinsifier::ObjectArray_Allocate(Assembler* assembler) {
31 // This snippet of inlined code uses the following registers: 30 // This snippet of inlined code uses the following registers:
32 // EAX, EBX, EDI 31 // EAX, EBX, EDI
33 // and the newly allocated object is returned in EAX. 32 // and the newly allocated object is returned in EAX.
34 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; 33 const intptr_t kTypeArgumentsOffset = 2 * kWordSize;
35 const intptr_t kArrayLengthOffset = 1 * kWordSize; 34 const intptr_t kArrayLengthOffset = 1 * kWordSize;
36 Label fall_through; 35 Label fall_through;
37 36
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 return false; 413 return false;
415 } 414 }
416 __ movl(EAX, Address(ESP, + 2 * kWordSize)); 415 __ movl(EAX, Address(ESP, + 2 * kWordSize));
417 __ movl(EBX, Address(ESP, + 1 * kWordSize)); 416 __ movl(EBX, Address(ESP, + 1 * kWordSize));
418 __ movl(FieldAddress(EAX, GrowableObjectArray::data_offset()), EBX); 417 __ movl(FieldAddress(EAX, GrowableObjectArray::data_offset()), EBX);
419 __ ret(); 418 __ ret();
420 return true; 419 return true;
421 } 420 }
422 421
423 422
424 // Handles only class InternalByteArray.
425 bool Intrinsifier::ByteArrayBase_getLength(Assembler* assembler) {
426 ObjectStore* object_store = Isolate::Current()->object_store();
427 Label fall_through;
428 __ movl(EAX, Address(ESP, + 1 * kWordSize));
429 __ movl(EBX, FieldAddress(EAX, Object::class_offset()));
430 __ CompareObject(EBX,
431 Class::ZoneHandle(object_store->internal_byte_array_class()));
432 __ j(NOT_EQUAL, &fall_through);
433 __ movl(EAX, FieldAddress(EAX, InternalByteArray::length_offset()));
434 __ ret();
435 __ Bind(&fall_through);
436 return false;
437 }
438
439
440 // Handles only class InternalByteArray.
441 bool Intrinsifier::ByteArrayBase_getIndexed(Assembler* assembler) {
442 ObjectStore* object_store = Isolate::Current()->object_store();
443 Label fall_through;
444 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array.
445 __ movl(EBX, FieldAddress(EAX, Object::class_offset()));
446 __ CompareObject(EBX,
447 Class::ZoneHandle(object_store->internal_byte_array_class()));
448 __ j(NOT_EQUAL, &fall_through);
449 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index.
450 __ testl(EBX, Immediate(kSmiTagMask));
451 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index.
452 // Range check.
453 __ cmpl(EBX, FieldAddress(EAX, InternalByteArray::length_offset()));
454 // Runtime throws exception.
455 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump);
456 __ SmiUntag(EBX);
457 __ movzxb(EAX,
458 FieldAddress(EAX, EBX, TIMES_1, InternalByteArray::data_offset()));
459 // The values stored in the byte array are regular, untagged values,
460 // therefore they need to be tagged.
461 __ SmiTag(EAX);
462 __ ret();
463 __ Bind(&fall_through);
464 return false;
465 }
466
467
468 // Tests if two top most arguments are smis, jumps to label not_smi if not. 423 // Tests if two top most arguments are smis, jumps to label not_smi if not.
469 // Topmost argument is in EAX. 424 // Topmost argument is in EAX.
470 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { 425 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) {
471 __ movl(EAX, Address(ESP, + 1 * kWordSize)); 426 __ movl(EAX, Address(ESP, + 1 * kWordSize));
472 __ movl(EBX, Address(ESP, + 2 * kWordSize)); 427 __ movl(EBX, Address(ESP, + 2 * kWordSize));
473 __ orl(EBX, EAX); 428 __ orl(EBX, EAX);
474 __ testl(EBX, Immediate(kSmiTagMask)); 429 __ testl(EBX, Immediate(kSmiTagMask));
475 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); 430 __ j(NOT_ZERO, not_smi, Assembler::kNearJump);
476 } 431 }
477 432
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 __ Bind(&is_true); 1281 __ Bind(&is_true);
1327 __ LoadObject(EAX, bool_true); 1282 __ LoadObject(EAX, bool_true);
1328 __ ret(); 1283 __ ret();
1329 return true; 1284 return true;
1330 } 1285 }
1331 1286
1332 #undef __ 1287 #undef __
1333 } // namespace dart 1288 } // namespace dart
1334 1289
1335 #endif // defined TARGET_ARCH_IA32 1290 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698