| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 Register scratch1, | 249 Register scratch1, |
| 250 Register scratch2, | 250 Register scratch2, |
| 251 int index, | 251 int index, |
| 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 __ test(receiver, Immediate(kSmiTagMask)); | 254 __ test(receiver, Immediate(kSmiTagMask)); |
| 255 __ j(zero, miss_label, not_taken); | 255 __ j(zero, miss_label, not_taken); |
| 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 // Get the value from the properties. | 261 // Get the value from the properties. |
| 262 GenerateFastPropertyLoad(masm, eax, reg, holder, index); | 262 GenerateFastPropertyLoad(masm, eax, reg, holder, index); |
| 263 __ ret(0); | 263 __ ret(0); |
| 264 } | 264 } |
| 265 | 265 |
| 266 | 266 |
| 267 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, | 267 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, |
| 268 JSObject* object, | 268 JSObject* object, |
| 269 JSObject* holder, | 269 JSObject* holder, |
| 270 Register receiver, | 270 Register receiver, |
| 271 Register name, | 271 Register name, |
| 272 Register scratch1, | 272 Register scratch1, |
| 273 Register scratch2, | 273 Register scratch2, |
| 274 AccessorInfo* callback, | 274 AccessorInfo* callback, |
| 275 Label* miss_label) { | 275 Label* miss_label) { |
| 276 // Check that the receiver isn't a smi. | 276 // Check that the receiver isn't a smi. |
| 277 __ test(receiver, Immediate(kSmiTagMask)); | 277 __ test(receiver, Immediate(kSmiTagMask)); |
| 278 __ j(zero, miss_label, not_taken); | 278 __ j(zero, miss_label, not_taken); |
| 279 | 279 |
| 280 // Check that the maps haven't changed. | 280 // Check that the maps haven't changed. |
| 281 Register reg = | 281 Register reg = |
| 282 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 282 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 283 | 283 |
| 284 // Push the arguments on the JS stack of the caller. | 284 // Push the arguments on the JS stack of the caller. |
| 285 __ pop(scratch2); // remove return address | 285 __ pop(scratch2); // remove return address |
| 286 __ push(receiver); // receiver | 286 __ push(receiver); // receiver |
| 287 __ push(Immediate(Handle<AccessorInfo>(callback))); // callback data | 287 __ push(Immediate(Handle<AccessorInfo>(callback))); // callback data |
| 288 __ push(name); // name | 288 __ push(name); // name |
| 289 __ push(reg); // holder | 289 __ push(reg); // holder |
| 290 __ push(scratch2); // restore return address | 290 __ push(scratch2); // restore return address |
| 291 | 291 |
| 292 // Do tail-call to the runtime system. | 292 // Do tail-call to the runtime system. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 303 Register scratch1, | 303 Register scratch1, |
| 304 Register scratch2, | 304 Register scratch2, |
| 305 Object* value, | 305 Object* value, |
| 306 Label* miss_label) { | 306 Label* miss_label) { |
| 307 // Check that the receiver isn't a smi. | 307 // Check that the receiver isn't a smi. |
| 308 __ test(receiver, Immediate(kSmiTagMask)); | 308 __ test(receiver, Immediate(kSmiTagMask)); |
| 309 __ j(zero, miss_label, not_taken); | 309 __ j(zero, miss_label, not_taken); |
| 310 | 310 |
| 311 // Check that the maps haven't changed. | 311 // Check that the maps haven't changed. |
| 312 Register reg = | 312 Register reg = |
| 313 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 313 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 314 | 314 |
| 315 // Return the constant value. | 315 // Return the constant value. |
| 316 __ mov(eax, Handle<Object>(value)); | 316 __ mov(eax, Handle<Object>(value)); |
| 317 __ ret(0); | 317 __ ret(0); |
| 318 } | 318 } |
| 319 | 319 |
| 320 | 320 |
| 321 void StubCompiler::GenerateLoadInterceptor(MacroAssembler* masm, | 321 void StubCompiler::GenerateLoadInterceptor(MacroAssembler* masm, |
| 322 JSObject* object, | 322 JSObject* object, |
| 323 JSObject* holder, | 323 JSObject* holder, |
| 324 Register receiver, | 324 Register receiver, |
| 325 Register name, | 325 Register name, |
| 326 Register scratch1, | 326 Register scratch1, |
| 327 Register scratch2, | 327 Register scratch2, |
| 328 Label* miss_label) { | 328 Label* miss_label) { |
| 329 // Check that the receiver isn't a smi. | 329 // Check that the receiver isn't a smi. |
| 330 __ test(receiver, Immediate(kSmiTagMask)); | 330 __ test(receiver, Immediate(kSmiTagMask)); |
| 331 __ j(zero, miss_label, not_taken); | 331 __ j(zero, miss_label, not_taken); |
| 332 | 332 |
| 333 // Check that the maps haven't changed. | 333 // Check that the maps haven't changed. |
| 334 Register reg = | 334 Register reg = |
| 335 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 335 masm->CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 336 | 336 |
| 337 // Push the arguments on the JS stack of the caller. | 337 // Push the arguments on the JS stack of the caller. |
| 338 __ pop(scratch2); // remove return address | 338 __ pop(scratch2); // remove return address |
| 339 __ push(receiver); // receiver | 339 __ push(receiver); // receiver |
| 340 __ push(reg); // holder | 340 __ push(reg); // holder |
| 341 __ push(name); // name | 341 __ push(name); // name |
| 342 __ push(scratch2); // restore return address | 342 __ push(scratch2); // restore return address |
| 343 | 343 |
| 344 // Do tail-call to the runtime system. | 344 // Do tail-call to the runtime system. |
| 345 ExternalReference load_ic_property = | 345 ExternalReference load_ic_property = |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 __ RecordWrite(scratch, offset, name_reg, receiver_reg); | 433 __ RecordWrite(scratch, offset, name_reg, receiver_reg); |
| 434 } | 434 } |
| 435 | 435 |
| 436 // Return the value (register eax). | 436 // Return the value (register eax). |
| 437 __ ret(0); | 437 __ ret(0); |
| 438 } | 438 } |
| 439 | 439 |
| 440 | 440 |
| 441 #undef __ | 441 #undef __ |
| 442 | 442 |
| 443 #define __ masm()-> | 443 #define __ DEFINE_MASM(masm()) |
| 444 | 444 |
| 445 | 445 |
| 446 // TODO(1241006): Avoid having lazy compile stubs specialized by the | 446 // TODO(1241006): Avoid having lazy compile stubs specialized by the |
| 447 // number of arguments. It is not needed anymore. | 447 // number of arguments. It is not needed anymore. |
| 448 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { | 448 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { |
| 449 // Enter an internal frame. | 449 // Enter an internal frame. |
| 450 __ EnterInternalFrame(); | 450 __ EnterInternalFrame(); |
| 451 | 451 |
| 452 // Push a copy of the function onto the stack. | 452 // Push a copy of the function onto the stack. |
| 453 __ push(edi); | 453 __ push(edi); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 478 // Get the receiver from the stack. | 478 // Get the receiver from the stack. |
| 479 const int argc = arguments().immediate(); | 479 const int argc = arguments().immediate(); |
| 480 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 480 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 481 | 481 |
| 482 // Check that the receiver isn't a smi. | 482 // Check that the receiver isn't a smi. |
| 483 __ test(edx, Immediate(kSmiTagMask)); | 483 __ test(edx, Immediate(kSmiTagMask)); |
| 484 __ j(zero, &miss, not_taken); | 484 __ j(zero, &miss, not_taken); |
| 485 | 485 |
| 486 // Do the right check and compute the holder register. | 486 // Do the right check and compute the holder register. |
| 487 Register reg = | 487 Register reg = |
| 488 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | 488 masm()->CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); |
| 489 | 489 |
| 490 GenerateFastPropertyLoad(masm(), edi, reg, holder, index); | 490 GenerateFastPropertyLoad(masm(), edi, reg, holder, index); |
| 491 | 491 |
| 492 // Check that the function really is a function. | 492 // Check that the function really is a function. |
| 493 __ test(edi, Immediate(kSmiTagMask)); | 493 __ test(edi, Immediate(kSmiTagMask)); |
| 494 __ j(zero, &miss, not_taken); | 494 __ j(zero, &miss, not_taken); |
| 495 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx); | 495 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx); |
| 496 __ j(not_equal, &miss, not_taken); | 496 __ j(not_equal, &miss, not_taken); |
| 497 | 497 |
| 498 // Patch the receiver on the stack with the global proxy if | 498 // Patch the receiver on the stack with the global proxy if |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 | 649 |
| 650 // Get the receiver from the stack. | 650 // Get the receiver from the stack. |
| 651 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 651 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 652 | 652 |
| 653 // Check that the receiver isn't a smi. | 653 // Check that the receiver isn't a smi. |
| 654 __ test(edx, Immediate(kSmiTagMask)); | 654 __ test(edx, Immediate(kSmiTagMask)); |
| 655 __ j(zero, &miss, not_taken); | 655 __ j(zero, &miss, not_taken); |
| 656 | 656 |
| 657 // Check that maps have not changed and compute the holder register. | 657 // Check that maps have not changed and compute the holder register. |
| 658 Register reg = | 658 Register reg = |
| 659 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | 659 masm()->CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); |
| 660 | 660 |
| 661 // Enter an internal frame. | 661 // Enter an internal frame. |
| 662 __ EnterInternalFrame(); | 662 __ EnterInternalFrame(); |
| 663 | 663 |
| 664 // Push arguments on the expression stack. | 664 // Push arguments on the expression stack. |
| 665 __ push(edx); // receiver | 665 __ push(edx); // receiver |
| 666 __ push(reg); // holder | 666 __ push(reg); // holder |
| 667 __ push(Operand(ebp, (argc + 3) * kPointerSize)); // name | 667 __ push(Operand(ebp, (argc + 3) * kPointerSize)); // name |
| 668 | 668 |
| 669 // Perform call. | 669 // Perform call. |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 1170 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 1171 | 1171 |
| 1172 // Return the generated code. | 1172 // Return the generated code. |
| 1173 return GetCode(CALLBACKS, name); | 1173 return GetCode(CALLBACKS, name); |
| 1174 } | 1174 } |
| 1175 | 1175 |
| 1176 | 1176 |
| 1177 #undef __ | 1177 #undef __ |
| 1178 | 1178 |
| 1179 } } // namespace v8::internal | 1179 } } // namespace v8::internal |
| OLD | NEW |