| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 | 368 |
| 369 // Generate code to load the length from a string object and return the length. | 369 // Generate code to load the length from a string object and return the length. |
| 370 // If the receiver object is not a string or a wrapped string object the | 370 // If the receiver object is not a string or a wrapped string object the |
| 371 // execution continues at the miss label. The register containing the | 371 // execution continues at the miss label. The register containing the |
| 372 // receiver is potentially clobbered. | 372 // receiver is potentially clobbered. |
| 373 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | 373 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, |
| 374 Register receiver, | 374 Register receiver, |
| 375 Register scratch1, | 375 Register scratch1, |
| 376 Register scratch2, | 376 Register scratch2, |
| 377 Label* miss, | 377 Label* miss) { |
| 378 bool support_wrappers) { | |
| 379 Label check_wrapper; | 378 Label check_wrapper; |
| 380 | 379 |
| 381 // Check if the object is a string leaving the instance type in the | 380 // Check if the object is a string leaving the instance type in the |
| 382 // scratch1 register. | 381 // scratch1 register. |
| 383 GenerateStringCheck(masm, receiver, scratch1, scratch2, miss, | 382 GenerateStringCheck(masm, receiver, scratch1, scratch2, miss, &check_wrapper); |
| 384 support_wrappers ? &check_wrapper : miss); | |
| 385 | 383 |
| 386 // Load length directly from the string. | 384 // Load length directly from the string. |
| 387 __ Ret(USE_DELAY_SLOT); | 385 __ Ret(USE_DELAY_SLOT); |
| 388 __ lw(v0, FieldMemOperand(receiver, String::kLengthOffset)); | 386 __ lw(v0, FieldMemOperand(receiver, String::kLengthOffset)); |
| 389 | 387 |
| 390 if (support_wrappers) { | 388 // Check if the object is a JSValue wrapper. |
| 391 // Check if the object is a JSValue wrapper. | 389 __ bind(&check_wrapper); |
| 392 __ bind(&check_wrapper); | 390 __ Branch(miss, ne, scratch1, Operand(JS_VALUE_TYPE)); |
| 393 __ Branch(miss, ne, scratch1, Operand(JS_VALUE_TYPE)); | |
| 394 | 391 |
| 395 // Unwrap the value and check if the wrapped value is a string. | 392 // Unwrap the value and check if the wrapped value is a string. |
| 396 __ lw(scratch1, FieldMemOperand(receiver, JSValue::kValueOffset)); | 393 __ lw(scratch1, FieldMemOperand(receiver, JSValue::kValueOffset)); |
| 397 GenerateStringCheck(masm, scratch1, scratch2, scratch2, miss, miss); | 394 GenerateStringCheck(masm, scratch1, scratch2, scratch2, miss, miss); |
| 398 __ Ret(USE_DELAY_SLOT); | 395 __ Ret(USE_DELAY_SLOT); |
| 399 __ lw(v0, FieldMemOperand(scratch1, String::kLengthOffset)); | 396 __ lw(v0, FieldMemOperand(scratch1, String::kLengthOffset)); |
| 400 } | |
| 401 } | 397 } |
| 402 | 398 |
| 403 | 399 |
| 404 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | 400 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
| 405 Register receiver, | 401 Register receiver, |
| 406 Register scratch1, | 402 Register scratch1, |
| 407 Register scratch2, | 403 Register scratch2, |
| 408 Label* miss_label) { | 404 Label* miss_label) { |
| 409 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 405 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
| 410 __ Ret(USE_DELAY_SLOT); | 406 __ Ret(USE_DELAY_SLOT); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 : CALL_AS_METHOD; | 766 : CALL_AS_METHOD; |
| 771 __ InvokeFunction(a1, arguments, JUMP_FUNCTION, NullCallWrapper(), call_kind); | 767 __ InvokeFunction(a1, arguments, JUMP_FUNCTION, NullCallWrapper(), call_kind); |
| 772 } | 768 } |
| 773 | 769 |
| 774 | 770 |
| 775 static void PushInterceptorArguments(MacroAssembler* masm, | 771 static void PushInterceptorArguments(MacroAssembler* masm, |
| 776 Register receiver, | 772 Register receiver, |
| 777 Register holder, | 773 Register holder, |
| 778 Register name, | 774 Register name, |
| 779 Handle<JSObject> holder_obj) { | 775 Handle<JSObject> holder_obj) { |
| 776 STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0); |
| 777 STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1); |
| 778 STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2); |
| 779 STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3); |
| 780 STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4); |
| 780 __ push(name); | 781 __ push(name); |
| 781 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); | 782 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); |
| 782 ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); | 783 ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); |
| 783 Register scratch = name; | 784 Register scratch = name; |
| 784 __ li(scratch, Operand(interceptor)); | 785 __ li(scratch, Operand(interceptor)); |
| 785 __ Push(scratch, receiver, holder); | 786 __ Push(scratch, receiver, holder); |
| 786 __ lw(scratch, FieldMemOperand(scratch, InterceptorInfo::kDataOffset)); | |
| 787 __ push(scratch); | |
| 788 __ li(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); | |
| 789 __ push(scratch); | |
| 790 } | 787 } |
| 791 | 788 |
| 792 | 789 |
| 793 static void CompileCallLoadPropertyWithInterceptor( | 790 static void CompileCallLoadPropertyWithInterceptor( |
| 794 MacroAssembler* masm, | 791 MacroAssembler* masm, |
| 795 Register receiver, | 792 Register receiver, |
| 796 Register holder, | 793 Register holder, |
| 797 Register name, | 794 Register name, |
| 798 Handle<JSObject> holder_obj) { | 795 Handle<JSObject> holder_obj) { |
| 799 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 796 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
| 800 | 797 |
| 801 ExternalReference ref = | 798 ExternalReference ref = |
| 802 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), | 799 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), |
| 803 masm->isolate()); | 800 masm->isolate()); |
| 804 __ PrepareCEntryArgs(6); | 801 __ PrepareCEntryArgs(StubCache::kInterceptorArgsLength); |
| 805 __ PrepareCEntryFunction(ref); | 802 __ PrepareCEntryFunction(ref); |
| 806 | 803 |
| 807 CEntryStub stub(1); | 804 CEntryStub stub(1); |
| 808 __ CallStub(&stub); | 805 __ CallStub(&stub); |
| 809 } | 806 } |
| 810 | 807 |
| 811 | 808 |
| 812 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; | 809 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; |
| 813 | 810 |
| 814 // Reserves space for the extra arguments to API function in the | 811 // Reserves space for the extra arguments to API function in the |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 FrameScope scope(masm, StackFrame::INTERNAL); | 1097 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1101 // Save the name_ register across the call. | 1098 // Save the name_ register across the call. |
| 1102 __ push(name_); | 1099 __ push(name_); |
| 1103 | 1100 |
| 1104 PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder); | 1101 PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder); |
| 1105 | 1102 |
| 1106 __ CallExternalReference( | 1103 __ CallExternalReference( |
| 1107 ExternalReference( | 1104 ExternalReference( |
| 1108 IC_Utility(IC::kLoadPropertyWithInterceptorForCall), | 1105 IC_Utility(IC::kLoadPropertyWithInterceptorForCall), |
| 1109 masm->isolate()), | 1106 masm->isolate()), |
| 1110 6); | 1107 StubCache::kInterceptorArgsLength); |
| 1111 // Restore the name_ register. | 1108 // Restore the name_ register. |
| 1112 __ pop(name_); | 1109 __ pop(name_); |
| 1113 // Leave the internal frame. | 1110 // Leave the internal frame. |
| 1114 } | 1111 } |
| 1115 | 1112 |
| 1116 void LoadWithInterceptor(MacroAssembler* masm, | 1113 void LoadWithInterceptor(MacroAssembler* masm, |
| 1117 Register receiver, | 1114 Register receiver, |
| 1118 Register holder, | 1115 Register holder, |
| 1119 Handle<JSObject> holder_obj, | 1116 Handle<JSObject> holder_obj, |
| 1120 Register scratch, | 1117 Register scratch, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 GenerateFastApiCall( | 1405 GenerateFastApiCall( |
| 1409 masm(), call_optimization, receiver(), scratch3(), 0, NULL); | 1406 masm(), call_optimization, receiver(), scratch3(), 0, NULL); |
| 1410 } | 1407 } |
| 1411 | 1408 |
| 1412 | 1409 |
| 1413 void BaseLoadStubCompiler::GenerateLoadCallback( | 1410 void BaseLoadStubCompiler::GenerateLoadCallback( |
| 1414 Register reg, | 1411 Register reg, |
| 1415 Handle<ExecutableAccessorInfo> callback) { | 1412 Handle<ExecutableAccessorInfo> callback) { |
| 1416 // Build AccessorInfo::args_ list on the stack and push property name below | 1413 // Build AccessorInfo::args_ list on the stack and push property name below |
| 1417 // the exit frame to make GC aware of them and store pointers to them. | 1414 // the exit frame to make GC aware of them and store pointers to them. |
| 1415 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0); |
| 1416 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1); |
| 1417 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2); |
| 1418 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3); |
| 1419 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4); |
| 1420 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5); |
| 1421 ASSERT(!scratch2().is(reg)); |
| 1422 ASSERT(!scratch3().is(reg)); |
| 1423 ASSERT(!scratch4().is(reg)); |
| 1418 __ push(receiver()); | 1424 __ push(receiver()); |
| 1419 __ mov(scratch2(), sp); // scratch2 = AccessorInfo::args_ | 1425 __ mov(scratch2(), sp); // scratch2 = AccessorInfo::args_ |
| 1420 if (heap()->InNewSpace(callback->data())) { | 1426 if (heap()->InNewSpace(callback->data())) { |
| 1421 __ li(scratch3(), callback); | 1427 __ li(scratch3(), callback); |
| 1422 __ lw(scratch3(), FieldMemOperand(scratch3(), | 1428 __ lw(scratch3(), FieldMemOperand(scratch3(), |
| 1423 ExecutableAccessorInfo::kDataOffset)); | 1429 ExecutableAccessorInfo::kDataOffset)); |
| 1424 } else { | 1430 } else { |
| 1425 __ li(scratch3(), Handle<Object>(callback->data(), isolate())); | 1431 __ li(scratch3(), Handle<Object>(callback->data(), isolate())); |
| 1426 } | 1432 } |
| 1427 __ Subu(sp, sp, 6 * kPointerSize); | 1433 __ Subu(sp, sp, 6 * kPointerSize); |
| 1428 __ sw(reg, MemOperand(sp, 5 * kPointerSize)); | 1434 __ sw(scratch3(), MemOperand(sp, 5 * kPointerSize)); |
| 1435 __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex); |
| 1429 __ sw(scratch3(), MemOperand(sp, 4 * kPointerSize)); | 1436 __ sw(scratch3(), MemOperand(sp, 4 * kPointerSize)); |
| 1430 __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex); | |
| 1431 __ sw(scratch3(), MemOperand(sp, 3 * kPointerSize)); | 1437 __ sw(scratch3(), MemOperand(sp, 3 * kPointerSize)); |
| 1432 __ sw(scratch3(), MemOperand(sp, 2 * kPointerSize)); | |
| 1433 __ li(scratch4(), | 1438 __ li(scratch4(), |
| 1434 Operand(ExternalReference::isolate_address(isolate()))); | 1439 Operand(ExternalReference::isolate_address(isolate()))); |
| 1435 __ sw(scratch4(), MemOperand(sp, 1 * kPointerSize)); | 1440 __ sw(scratch4(), MemOperand(sp, 2 * kPointerSize)); |
| 1441 __ sw(reg, MemOperand(sp, 1 * kPointerSize)); |
| 1436 __ sw(name(), MemOperand(sp, 0 * kPointerSize)); | 1442 __ sw(name(), MemOperand(sp, 0 * kPointerSize)); |
| 1437 | 1443 |
| 1438 __ mov(a2, scratch2()); // Saved in case scratch2 == a1. | 1444 __ mov(a2, scratch2()); // Saved in case scratch2 == a1. |
| 1439 __ mov(a0, sp); // (first argument - a0) = Handle<Name> | 1445 __ mov(a0, sp); // (first argument - a0) = Handle<Name> |
| 1440 | 1446 |
| 1441 const int kApiStackSpace = 1; | 1447 const int kApiStackSpace = 1; |
| 1442 FrameScope frame_scope(masm(), StackFrame::MANUAL); | 1448 FrameScope frame_scope(masm(), StackFrame::MANUAL); |
| 1443 __ EnterExitFrame(false, kApiStackSpace); | 1449 __ EnterExitFrame(false, kApiStackSpace); |
| 1444 | 1450 |
| 1445 // Create AccessorInfo instance on the stack above the exit frame with | 1451 // Create AccessorInfo instance on the stack above the exit frame with |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1458 ExternalReference::Type thunk_type = | 1464 ExternalReference::Type thunk_type = |
| 1459 ExternalReference::PROFILING_GETTER_CALL; | 1465 ExternalReference::PROFILING_GETTER_CALL; |
| 1460 ApiFunction thunk_fun(thunk_address); | 1466 ApiFunction thunk_fun(thunk_address); |
| 1461 ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type, | 1467 ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type, |
| 1462 isolate()); | 1468 isolate()); |
| 1463 __ CallApiFunctionAndReturn(ref, | 1469 __ CallApiFunctionAndReturn(ref, |
| 1464 getter_address, | 1470 getter_address, |
| 1465 thunk_ref, | 1471 thunk_ref, |
| 1466 a2, | 1472 a2, |
| 1467 kStackUnwindSpace, | 1473 kStackUnwindSpace, |
| 1468 5); | 1474 6); |
| 1469 } | 1475 } |
| 1470 | 1476 |
| 1471 | 1477 |
| 1472 void BaseLoadStubCompiler::GenerateLoadInterceptor( | 1478 void BaseLoadStubCompiler::GenerateLoadInterceptor( |
| 1473 Register holder_reg, | 1479 Register holder_reg, |
| 1474 Handle<JSObject> object, | 1480 Handle<JSObject> object, |
| 1475 Handle<JSObject> interceptor_holder, | 1481 Handle<JSObject> interceptor_holder, |
| 1476 LookupResult* lookup, | 1482 LookupResult* lookup, |
| 1477 Handle<Name> name) { | 1483 Handle<Name> name) { |
| 1478 ASSERT(interceptor_holder->HasNamedInterceptor()); | 1484 ASSERT(interceptor_holder->HasNamedInterceptor()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 } | 1549 } |
| 1544 GenerateLoadPostInterceptor(holder_reg, interceptor_holder, name, lookup); | 1550 GenerateLoadPostInterceptor(holder_reg, interceptor_holder, name, lookup); |
| 1545 } else { // !compile_followup_inline | 1551 } else { // !compile_followup_inline |
| 1546 // Call the runtime system to load the interceptor. | 1552 // Call the runtime system to load the interceptor. |
| 1547 // Check that the maps haven't changed. | 1553 // Check that the maps haven't changed. |
| 1548 PushInterceptorArguments(masm(), receiver(), holder_reg, | 1554 PushInterceptorArguments(masm(), receiver(), holder_reg, |
| 1549 this->name(), interceptor_holder); | 1555 this->name(), interceptor_holder); |
| 1550 | 1556 |
| 1551 ExternalReference ref = ExternalReference( | 1557 ExternalReference ref = ExternalReference( |
| 1552 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), isolate()); | 1558 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), isolate()); |
| 1553 __ TailCallExternalReference(ref, 6, 1); | 1559 __ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1); |
| 1554 } | 1560 } |
| 1555 } | 1561 } |
| 1556 | 1562 |
| 1557 | 1563 |
| 1558 void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) { | 1564 void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) { |
| 1559 if (kind_ == Code::KEYED_CALL_IC) { | 1565 if (kind_ == Code::KEYED_CALL_IC) { |
| 1560 __ Branch(miss, ne, a2, Operand(name)); | 1566 __ Branch(miss, ne, a2, Operand(name)); |
| 1561 } | 1567 } |
| 1562 } | 1568 } |
| 1563 | 1569 |
| (...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3184 // ----------------------------------- | 3190 // ----------------------------------- |
| 3185 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3191 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
| 3186 } | 3192 } |
| 3187 | 3193 |
| 3188 | 3194 |
| 3189 #undef __ | 3195 #undef __ |
| 3190 | 3196 |
| 3191 } } // namespace v8::internal | 3197 } } // namespace v8::internal |
| 3192 | 3198 |
| 3193 #endif // V8_TARGET_ARCH_MIPS | 3199 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |