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

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

Issue 8984003: Port code generator to x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler_macros.h" 8 #include "vm/assembler_macros.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 DECLARE_FLAG(bool, inline_alloc); 14 DECLARE_FLAG(bool, inline_alloc);
15 15
16 #define __ assembler-> 16 #define __ assembler->
17 17
18 // Static. 18 // Static.
19 void AssemblerMacros::TryAllocate(Assembler* assembler, 19 void AssemblerMacros::TryAllocate(Assembler* assembler,
20 const Class& cls, 20 const Class& cls,
21 Register class_reg, 21 Register class_reg,
22 Label* failure, 22 Label* failure,
23 Register instance_reg) { 23 Register instance_reg) {
24 #if defined(DEBUG) 24 #if defined(DEBUG)
25 __ Untested("AssemblerMacros::TryAllocate"); 25 __ Untested("AssemblerMacros::TryAllocate");
26 Label ok; 26 Label ok;
27 __ LoadObject(instance_reg, cls); 27 __ LoadObject(instance_reg, cls);
28 __ cmpl(instance_reg, class_reg); 28 __ cmpq(instance_reg, class_reg);
29 __ j(EQUAL, &ok, Assembler::kNearJump); 29 __ j(EQUAL, &ok, Assembler::kNearJump);
30 __ Stop("AssemblerMacros::TryAllocate, wrong arguments"); 30 __ Stop("AssemblerMacros::TryAllocate, wrong arguments");
31 __ Bind(&ok); 31 __ Bind(&ok);
32 #endif 32 #endif
33 ASSERT(failure != NULL); 33 ASSERT(failure != NULL);
34 ASSERT(class_reg != instance_reg); 34 ASSERT(class_reg != instance_reg);
35 if (FLAG_inline_alloc) { 35 if (FLAG_inline_alloc) {
36 Heap* heap = Isolate::Current()->heap(); 36 Heap* heap = Isolate::Current()->heap();
37 const intptr_t instance_size = cls.instance_size(); 37 const intptr_t instance_size = cls.instance_size();
38 __ movq(instance_reg, Address::Absolute(heap->TopAddress())); 38 __ movq(TMP, Immediate(heap->TopAddress()));
39 __ movq(instance_reg, Address(TMP, 0));
39 __ addq(instance_reg, Immediate(instance_size)); 40 __ addq(instance_reg, Immediate(instance_size));
40 // instance_reg: potential next object start. 41 // instance_reg: potential next object start.
41 __ cmpq(instance_reg, Address::Absolute(heap->EndAddress())); 42 __ movq(TMP, Immediate(heap->EndAddress()));
43 __ cmpq(instance_reg, Address(TMP, 0));
42 __ j(ABOVE_EQUAL, failure, Assembler::kNearJump); 44 __ j(ABOVE_EQUAL, failure, Assembler::kNearJump);
43 // Successfully allocated the object, now update top to point to 45 // Successfully allocated the object, now update top to point to
44 // next object start and store the class in the class field of object. 46 // next object start and store the class in the class field of object.
45 __ movq(Address::Absolute(heap->TopAddress()), instance_reg); 47 __ movq(TMP, Immediate(heap->TopAddress()));
48 __ movq(Address(TMP, 0), instance_reg);
46 ASSERT(instance_size >= kHeapObjectTag); 49 ASSERT(instance_size >= kHeapObjectTag);
47 __ subq(instance_reg, Immediate(instance_size - kHeapObjectTag)); 50 __ subq(instance_reg, Immediate(instance_size - kHeapObjectTag));
48 __ movq(FieldAddress(instance_reg, Instance::class_offset()), class_reg); 51 __ movq(FieldAddress(instance_reg, Instance::class_offset()), class_reg);
49 } else { 52 } else {
50 __ jmp(failure); 53 __ jmp(failure);
51 } 54 }
52 } 55 }
53 56
54 #undef __ 57 #undef __
55 58
56 } // namespace dart 59 } // namespace dart
57 60
58 #endif // defined TARGET_ARCH_X64 61 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698