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

Side by Side Diff: src/arm/fast-codegen-arm.cc

Issue 586002: Added helper functions for fixed register allocation. (Closed)
Patch Set: Created 10 years, 10 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
« no previous file with comments | « no previous file | src/fast-codegen.h » ('j') | src/ia32/fast-codegen-ia32.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 17 matching lines...) Expand all
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "codegen-inl.h" 30 #include "codegen-inl.h"
31 #include "fast-codegen.h" 31 #include "fast-codegen.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 #define __ ACCESS_MASM(masm()) 36 #define __ ACCESS_MASM(masm())
37 37
38 void FastCodeGenerator::EmitLoadReceiver(Register reg) { 38 Register FastCodeGenerator::accumulator0() { return r0; }
39 Register FastCodeGenerator::accumulator1() { return r1; }
40 Register FastCodeGenerator::scratch0() { return r3; }
41 Register FastCodeGenerator::scratch1() { return r4; }
42 Register FastCodeGenerator::receiver_reg() { return r2; }
43 Register FastCodeGenerator::context_reg() { return cp; }
44
45
46 void FastCodeGenerator::EmitLoadReceiver() {
39 // Offset 2 is due to return address and saved frame pointer. 47 // Offset 2 is due to return address and saved frame pointer.
40 int index = 2 + scope()->num_parameters(); 48 int index = 2 + scope()->num_parameters();
41 __ ldr(reg, MemOperand(sp, index * kPointerSize)); 49 __ ldr(receiver_reg(), MemOperand(sp, index * kPointerSize));
42 }
43
44
45 void FastCodeGenerator::EmitReceiverMapCheck() {
46 Comment cmnt(masm(), ";; MapCheck(this)");
47 if (FLAG_print_ir) {
48 PrintF("MapCheck(this)\n");
49 }
50
51 ASSERT(info()->has_receiver() && info()->receiver()->IsHeapObject());
52 Handle<HeapObject> object = Handle<HeapObject>::cast(info()->receiver());
53 Handle<Map> map(object->map());
54
55 EmitLoadReceiver(r1);
56 __ CheckMap(r1, r3, map, bailout(), false);
57 }
58
59
60 void FastCodeGenerator::EmitGlobalMapCheck() {
61 Comment cmnt(masm(), ";; GlobalMapCheck");
62 if (FLAG_print_ir) {
63 PrintF(";; GlobalMapCheck()");
64 }
65
66 ASSERT(info()->has_global_object());
67 Handle<Map> map(info()->global_object()->map());
68
69 __ ldr(r3, CodeGenerator::GlobalObject());
70 __ CheckMap(r3, r3, map, bailout(), true);
71 } 50 }
72 51
73 52
74 void FastCodeGenerator::EmitGlobalVariableLoad(Handle<Object> cell) { 53 void FastCodeGenerator::EmitGlobalVariableLoad(Handle<Object> cell) {
75 ASSERT(cell->IsJSGlobalPropertyCell()); 54 ASSERT(cell->IsJSGlobalPropertyCell());
76 __ mov(r0, Operand(cell)); 55 __ mov(accumulator0(), Operand(cell));
77 __ ldr(r0, FieldMemOperand(r0, JSGlobalPropertyCell::kValueOffset)); 56 __ ldr(accumulator0(),
57 FieldMemOperand(accumulator0(), JSGlobalPropertyCell::kValueOffset));
78 if (FLAG_debug_code) { 58 if (FLAG_debug_code) {
79 __ mov(ip, Operand(Factory::the_hole_value())); 59 __ mov(ip, Operand(Factory::the_hole_value()));
80 __ cmp(r0, ip); 60 __ cmp(accumulator0(), ip);
81 __ Check(ne, "DontDelete cells can't contain the hole"); 61 __ Check(ne, "DontDelete cells can't contain the hole");
82 } 62 }
83 } 63 }
84 64
85 65
86 void FastCodeGenerator::EmitThisPropertyStore(Handle<String> name) { 66 void FastCodeGenerator::EmitThisPropertyStore(Handle<String> name) {
87 LookupResult lookup; 67 LookupResult lookup;
88 info()->receiver()->Lookup(*name, &lookup); 68 info()->receiver()->Lookup(*name, &lookup);
89 69
90 ASSERT(lookup.holder() == *info()->receiver()); 70 ASSERT(lookup.holder() == *info()->receiver());
91 ASSERT(lookup.type() == FIELD); 71 ASSERT(lookup.type() == FIELD);
92 Handle<Map> map(Handle<HeapObject>::cast(info()->receiver())->map()); 72 Handle<Map> map(Handle<HeapObject>::cast(info()->receiver())->map());
93 int index = lookup.GetFieldIndex() - map->inobject_properties(); 73 int index = lookup.GetFieldIndex() - map->inobject_properties();
94 int offset = index * kPointerSize; 74 int offset = index * kPointerSize;
95 75
96 // Negative offsets are inobject properties. 76 // Negative offsets are inobject properties.
97 if (offset < 0) { 77 if (offset < 0) {
98 offset += map->instance_size(); 78 offset += map->instance_size();
99 __ mov(r2, r1); // Copy receiver for write barrier. 79 __ mov(scratch0(), receiver_reg()); // Copy receiver for write barrier.
100 } else { 80 } else {
101 offset += FixedArray::kHeaderSize; 81 offset += FixedArray::kHeaderSize;
102 __ ldr(r2, FieldMemOperand(r1, JSObject::kPropertiesOffset)); 82 __ ldr(scratch0(),
83 FieldMemOperand(receiver_reg(), JSObject::kPropertiesOffset));
103 } 84 }
104 // Perform the store. 85 // Perform the store.
105 __ str(r0, FieldMemOperand(r2, offset)); 86 __ str(accumulator0(), FieldMemOperand(scratch0(), offset));
106 __ mov(r3, Operand(offset)); 87 __ mov(scratch1(), Operand(offset));
107 __ RecordWrite(r2, r3, ip); 88 __ RecordWrite(scratch0(), scratch1(), ip);
108 } 89 }
109 90
110 91
111 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) { 92 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) {
112 ASSERT(info_ == NULL); 93 ASSERT(info_ == NULL);
113 info_ = compilation_info; 94 info_ = compilation_info;
114 95
115 // Save the caller's frame pointer and set up our own. 96 // Save the caller's frame pointer and set up our own.
116 Comment prologue_cmnt(masm(), ";; Prologue"); 97 Comment prologue_cmnt(masm(), ";; Prologue");
117 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); 98 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit());
118 __ add(fp, sp, Operand(2 * kPointerSize)); 99 __ add(fp, sp, Operand(2 * kPointerSize));
119 // Note that we keep a live register reference to cp (context) at 100 // Note that we keep a live register reference to cp (context) at
120 // this point. 101 // this point.
121 102
122 // Receiver (this) is allocated to r1 if there are this properties. 103 // Receiver (this) is allocated to a fixed register.
123 if (info()->has_this_properties()) EmitReceiverMapCheck(); 104 if (info()->has_this_properties()) {
105 Comment cmnt(masm(), ";; MapCheck(this)");
106 if (FLAG_print_ir) {
107 PrintF("MapCheck(this)\n");
108 }
109 ASSERT(info()->has_receiver() && info()->receiver()->IsHeapObject());
110 Handle<HeapObject> object = Handle<HeapObject>::cast(info()->receiver());
111 Handle<Map> map(object->map());
112 EmitLoadReceiver();
113 __ CheckMap(receiver_reg(), scratch0(), map, bailout(), false);
114 }
124 115
125 // If there is a global variable access check if the global object 116 // If there is a global variable access check if the global object is the
126 // is the same as at lazy-compilation time. 117 // same as at lazy-compilation time.
127 if (info()->has_globals()) EmitGlobalMapCheck(); 118 if (info()->has_globals()) {
119 Comment cmnt(masm(), ";; MapCheck(GLOBAL)");
120 if (FLAG_print_ir) {
121 PrintF("MapCheck(GLOBAL)\n");
122 }
123 ASSERT(info()->has_global_object());
124 Handle<Map> map(info()->global_object()->map());
125 __ ldr(scratch0(), CodeGenerator::GlobalObject());
126 __ CheckMap(scratch0(), scratch1(), map, bailout(), true);
127 }
128 128
129 VisitStatements(function()->body()); 129 VisitStatements(function()->body());
130 130
131 Comment return_cmnt(masm(), ";; Return(<undefined>)"); 131 Comment return_cmnt(masm(), ";; Return(<undefined>)");
132 if (FLAG_print_ir) {
133 PrintF("Return(<undefined>)\n");
134 }
132 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); 135 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
133
134 Comment epilogue_cmnt(masm(), ";; Epilogue");
135 __ mov(sp, fp); 136 __ mov(sp, fp);
136 __ ldm(ia_w, sp, fp.bit() | lr.bit()); 137 __ ldm(ia_w, sp, fp.bit() | lr.bit());
137 int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize; 138 int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize;
138 __ add(sp, sp, Operand(sp_delta)); 139 __ add(sp, sp, Operand(sp_delta));
139 __ Jump(lr); 140 __ Jump(lr);
140 141
141 __ bind(&bailout_); 142 __ bind(&bailout_);
142 } 143 }
143 144
144 145
145 #undef __ 146 #undef __
146 147
147 148
148 } } // namespace v8::internal 149 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/fast-codegen.h » ('j') | src/ia32/fast-codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698