| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "ic-inl.h" | 30 #include "ic-inl.h" |
| 31 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
| 32 #include "stub-cache.h" | 32 #include "stub-cache.h" |
| 33 | 33 |
| 34 namespace v8 { namespace internal { | 34 namespace v8 { namespace internal { |
| 35 | 35 |
| 36 #define __ masm-> | 36 #define __ DEFINE_MASM(masm) |
| 37 | 37 |
| 38 | 38 |
| 39 static void ProbeTable(MacroAssembler* masm, | 39 static void ProbeTable(MacroAssembler* masm, |
| 40 Code::Flags flags, | 40 Code::Flags flags, |
| 41 StubCache::Table table, | 41 StubCache::Table table, |
| 42 Register name, | 42 Register name, |
| 43 Register offset) { | 43 Register offset) { |
| 44 ExternalReference key_offset(SCTableReference::keyReference(table)); | 44 ExternalReference key_offset(SCTableReference::keyReference(table)); |
| 45 ExternalReference value_offset(SCTableReference::valueReference(table)); | 45 ExternalReference value_offset(SCTableReference::valueReference(table)); |
| 46 | 46 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 Register scratch1, | 176 Register scratch1, |
| 177 Register scratch2, | 177 Register scratch2, |
| 178 int index, | 178 int index, |
| 179 Label* miss_label) { | 179 Label* miss_label) { |
| 180 // Check that the receiver isn't a smi. | 180 // Check that the receiver isn't a smi. |
| 181 __ tst(receiver, Operand(kSmiTagMask)); | 181 __ tst(receiver, Operand(kSmiTagMask)); |
| 182 __ b(eq, miss_label); | 182 __ b(eq, miss_label); |
| 183 | 183 |
| 184 // Check that the maps haven't changed. | 184 // Check that the maps haven't changed. |
| 185 Register reg = | 185 Register reg = |
| 186 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 186 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 187 GenerateFastPropertyLoad(masm, r0, reg, holder, index); | 187 GenerateFastPropertyLoad(masm, r0, reg, holder, index); |
| 188 __ Ret(); | 188 __ Ret(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 |
| 192 void StubCompiler::GenerateLoadConstant(MacroAssembler* masm, | 192 void StubCompiler::GenerateLoadConstant(MacroAssembler* masm, |
| 193 JSObject* object, | 193 JSObject* object, |
| 194 JSObject* holder, | 194 JSObject* holder, |
| 195 Register receiver, | 195 Register receiver, |
| 196 Register scratch1, | 196 Register scratch1, |
| 197 Register scratch2, | 197 Register scratch2, |
| 198 Object* value, | 198 Object* value, |
| 199 Label* miss_label) { | 199 Label* miss_label) { |
| 200 // Check that the receiver isn't a smi. | 200 // Check that the receiver isn't a smi. |
| 201 __ tst(receiver, Operand(kSmiTagMask)); | 201 __ tst(receiver, Operand(kSmiTagMask)); |
| 202 __ b(eq, miss_label); | 202 __ b(eq, miss_label); |
| 203 | 203 |
| 204 // Check that the maps haven't changed. | 204 // Check that the maps haven't changed. |
| 205 Register reg = | 205 Register reg = |
| 206 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 206 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 207 | 207 |
| 208 // Return the constant value. | 208 // Return the constant value. |
| 209 __ mov(r0, Operand(Handle<Object>(value))); | 209 __ mov(r0, Operand(Handle<Object>(value))); |
| 210 __ Ret(); | 210 __ Ret(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| 214 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, | 214 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, |
| 215 JSObject* object, | 215 JSObject* object, |
| 216 JSObject* holder, | 216 JSObject* holder, |
| 217 Register receiver, | 217 Register receiver, |
| 218 Register name, | 218 Register name, |
| 219 Register scratch1, | 219 Register scratch1, |
| 220 Register scratch2, | 220 Register scratch2, |
| 221 AccessorInfo* callback, | 221 AccessorInfo* callback, |
| 222 Label* miss_label) { | 222 Label* miss_label) { |
| 223 // Check that the receiver isn't a smi. | 223 // Check that the receiver isn't a smi. |
| 224 __ tst(receiver, Operand(kSmiTagMask)); | 224 __ tst(receiver, Operand(kSmiTagMask)); |
| 225 __ b(eq, miss_label); | 225 __ b(eq, miss_label); |
| 226 | 226 |
| 227 // Check that the maps haven't changed. | 227 // Check that the maps haven't changed. |
| 228 Register reg = | 228 Register reg = |
| 229 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 229 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 230 | 230 |
| 231 // Push the arguments on the JS stack of the caller. | 231 // Push the arguments on the JS stack of the caller. |
| 232 __ push(receiver); // receiver | 232 __ push(receiver); // receiver |
| 233 __ mov(ip, Operand(Handle<AccessorInfo>(callback))); // callback data | 233 __ mov(ip, Operand(Handle<AccessorInfo>(callback))); // callback data |
| 234 __ push(ip); | 234 __ push(ip); |
| 235 __ push(name); // name | 235 __ push(name); // name |
| 236 __ push(reg); // holder | 236 __ push(reg); // holder |
| 237 | 237 |
| 238 // Do tail-call to the runtime system. | 238 // Do tail-call to the runtime system. |
| 239 ExternalReference load_callback_property = | 239 ExternalReference load_callback_property = |
| 240 ExternalReference(IC_Utility(IC::kLoadCallbackProperty)); | 240 ExternalReference(IC_Utility(IC::kLoadCallbackProperty)); |
| 241 __ TailCallRuntime(load_callback_property, 4); | 241 __ TailCallRuntime(load_callback_property, 4); |
| 242 } | 242 } |
| 243 | 243 |
| 244 | 244 |
| 245 void StubCompiler::GenerateLoadInterceptor(MacroAssembler* masm, | 245 void StubCompiler::GenerateLoadInterceptor(MacroAssembler* masm, |
| 246 JSObject* object, | 246 JSObject* object, |
| 247 JSObject* holder, | 247 JSObject* holder, |
| 248 Register receiver, | 248 Register receiver, |
| 249 Register name, | 249 Register name, |
| 250 Register scratch1, | 250 Register scratch1, |
| 251 Register scratch2, | 251 Register scratch2, |
| 252 Label* miss_label) { | 252 Label* miss_label) { |
| 253 // Check that the receiver isn't a smi. | 253 // Check that the receiver isn't a smi. |
| 254 __ tst(receiver, Operand(kSmiTagMask)); | 254 __ tst(receiver, Operand(kSmiTagMask)); |
| 255 __ b(eq, miss_label); | 255 __ b(eq, miss_label); |
| 256 | 256 |
| 257 // Check that the maps haven't changed. | 257 // Check that the maps haven't changed. |
| 258 Register reg = | 258 Register reg = |
| 259 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 259 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 260 | 260 |
| 261 // Push the arguments on the JS stack of the caller. | 261 // Push the arguments on the JS stack of the caller. |
| 262 __ push(receiver); // receiver | 262 __ push(receiver); // receiver |
| 263 __ push(reg); // holder | 263 __ push(reg); // holder |
| 264 __ push(name); // name | 264 __ push(name); // name |
| 265 | 265 |
| 266 // Do tail-call to the runtime system. | 266 // Do tail-call to the runtime system. |
| 267 ExternalReference load_ic_property = | 267 ExternalReference load_ic_property = |
| 268 ExternalReference(IC_Utility(IC::kLoadInterceptorProperty)); | 268 ExternalReference(IC_Utility(IC::kLoadInterceptorProperty)); |
| 269 __ TailCallRuntime(load_ic_property, 3); | 269 __ TailCallRuntime(load_ic_property, 3); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 } else { | 449 } else { |
| 450 code = Builtins::builtin(Builtins::KeyedLoadIC_Miss); | 450 code = Builtins::builtin(Builtins::KeyedLoadIC_Miss); |
| 451 } | 451 } |
| 452 | 452 |
| 453 Handle<Code> ic(code); | 453 Handle<Code> ic(code); |
| 454 __ Jump(ic, RelocInfo::CODE_TARGET); | 454 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 455 } | 455 } |
| 456 | 456 |
| 457 | 457 |
| 458 #undef __ | 458 #undef __ |
| 459 | 459 #define __ DEFINE_MASM(masm()) |
| 460 #define __ masm()-> | |
| 461 | 460 |
| 462 | 461 |
| 463 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { | 462 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { |
| 464 // ----------- S t a t e ------------- | 463 // ----------- S t a t e ------------- |
| 465 // -- r1: function | 464 // -- r1: function |
| 466 // -- lr: return address | 465 // -- lr: return address |
| 467 // ----------------------------------- | 466 // ----------------------------------- |
| 468 | 467 |
| 469 // Enter an internal frame. | 468 // Enter an internal frame. |
| 470 __ EnterInternalFrame(); | 469 __ EnterInternalFrame(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 const int argc = arguments().immediate(); | 503 const int argc = arguments().immediate(); |
| 505 | 504 |
| 506 // Get the receiver of the function from the stack into r0. | 505 // Get the receiver of the function from the stack into r0. |
| 507 __ ldr(r0, MemOperand(sp, argc * kPointerSize)); | 506 __ ldr(r0, MemOperand(sp, argc * kPointerSize)); |
| 508 // Check that the receiver isn't a smi. | 507 // Check that the receiver isn't a smi. |
| 509 __ tst(r0, Operand(kSmiTagMask)); | 508 __ tst(r0, Operand(kSmiTagMask)); |
| 510 __ b(eq, &miss); | 509 __ b(eq, &miss); |
| 511 | 510 |
| 512 // Do the right check and compute the holder register. | 511 // Do the right check and compute the holder register. |
| 513 Register reg = | 512 Register reg = |
| 514 __ CheckMaps(JSObject::cast(object), r0, holder, r3, r2, &miss); | 513 masm()->CheckMaps(JSObject::cast(object), r0, holder, r3, r2, &miss); |
| 515 GenerateFastPropertyLoad(masm(), r1, reg, holder, index); | 514 GenerateFastPropertyLoad(masm(), r1, reg, holder, index); |
| 516 | 515 |
| 517 // Check that the function really is a function. | 516 // Check that the function really is a function. |
| 518 __ tst(r1, Operand(kSmiTagMask)); | 517 __ tst(r1, Operand(kSmiTagMask)); |
| 519 __ b(eq, &miss); | 518 __ b(eq, &miss); |
| 520 // Get the map. | 519 // Get the map. |
| 521 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); | 520 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 522 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | 521 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); |
| 523 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); | 522 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); |
| 524 __ b(ne, &miss); | 523 __ b(ne, &miss); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 __ Jump(ic, RelocInfo::CODE_TARGET); | 1115 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 1117 | 1116 |
| 1118 // Return the generated code. | 1117 // Return the generated code. |
| 1119 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); | 1118 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION, name); |
| 1120 } | 1119 } |
| 1121 | 1120 |
| 1122 | 1121 |
| 1123 #undef __ | 1122 #undef __ |
| 1124 | 1123 |
| 1125 } } // namespace v8::internal | 1124 } } // namespace v8::internal |
| OLD | NEW |