OLD | NEW |
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 7125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7136 // Return and remove the on-stack parameter. | 7136 // Return and remove the on-stack parameter. |
7137 __ ret(1 * kPointerSize); | 7137 __ ret(1 * kPointerSize); |
7138 | 7138 |
7139 // Create a new closure through the slower runtime call. | 7139 // Create a new closure through the slower runtime call. |
7140 __ bind(&gc); | 7140 __ bind(&gc); |
7141 __ pop(ecx); // Temporarily remove return address. | 7141 __ pop(ecx); // Temporarily remove return address. |
7142 __ pop(edx); | 7142 __ pop(edx); |
7143 __ push(esi); | 7143 __ push(esi); |
7144 __ push(edx); | 7144 __ push(edx); |
7145 __ push(ecx); // Restore return address. | 7145 __ push(ecx); // Restore return address. |
7146 __ TailCallRuntime(ExternalReference(Runtime::kNewClosure), 2, 1); | 7146 __ TailCallRuntime(Runtime::kNewClosure, 2, 1); |
7147 } | 7147 } |
7148 | 7148 |
7149 | 7149 |
7150 void FastNewContextStub::Generate(MacroAssembler* masm) { | 7150 void FastNewContextStub::Generate(MacroAssembler* masm) { |
7151 // Try to allocate the context in new space. | 7151 // Try to allocate the context in new space. |
7152 Label gc; | 7152 Label gc; |
7153 int length = slots_ + Context::MIN_CONTEXT_SLOTS; | 7153 int length = slots_ + Context::MIN_CONTEXT_SLOTS; |
7154 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, | 7154 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, |
7155 eax, ebx, ecx, &gc, TAG_OBJECT); | 7155 eax, ebx, ecx, &gc, TAG_OBJECT); |
7156 | 7156 |
(...skipping 23 matching lines...) Expand all Loading... |
7180 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { | 7180 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { |
7181 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); | 7181 __ mov(Operand(eax, Context::SlotOffset(i)), ebx); |
7182 } | 7182 } |
7183 | 7183 |
7184 // Return and remove the on-stack parameter. | 7184 // Return and remove the on-stack parameter. |
7185 __ mov(esi, Operand(eax)); | 7185 __ mov(esi, Operand(eax)); |
7186 __ ret(1 * kPointerSize); | 7186 __ ret(1 * kPointerSize); |
7187 | 7187 |
7188 // Need to collect. Call into runtime system. | 7188 // Need to collect. Call into runtime system. |
7189 __ bind(&gc); | 7189 __ bind(&gc); |
7190 __ TailCallRuntime(ExternalReference(Runtime::kNewContext), 1, 1); | 7190 __ TailCallRuntime(Runtime::kNewContext, 1, 1); |
7191 } | 7191 } |
7192 | 7192 |
7193 | 7193 |
7194 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { | 7194 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
7195 // Stack layout on entry: | 7195 // Stack layout on entry: |
7196 // | 7196 // |
7197 // [esp + kPointerSize]: constant elements. | 7197 // [esp + kPointerSize]: constant elements. |
7198 // [esp + (2 * kPointerSize)]: literal index. | 7198 // [esp + (2 * kPointerSize)]: literal index. |
7199 // [esp + (3 * kPointerSize)]: literals array. | 7199 // [esp + (3 * kPointerSize)]: literals array. |
7200 | 7200 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7235 for (int i = 0; i < elements_size; i += kPointerSize) { | 7235 for (int i = 0; i < elements_size; i += kPointerSize) { |
7236 __ mov(ebx, FieldOperand(ecx, i)); | 7236 __ mov(ebx, FieldOperand(ecx, i)); |
7237 __ mov(FieldOperand(edx, i), ebx); | 7237 __ mov(FieldOperand(edx, i), ebx); |
7238 } | 7238 } |
7239 } | 7239 } |
7240 | 7240 |
7241 // Return and remove the on-stack parameters. | 7241 // Return and remove the on-stack parameters. |
7242 __ ret(3 * kPointerSize); | 7242 __ ret(3 * kPointerSize); |
7243 | 7243 |
7244 __ bind(&slow_case); | 7244 __ bind(&slow_case); |
7245 ExternalReference runtime(Runtime::kCreateArrayLiteralShallow); | 7245 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
7246 __ TailCallRuntime(runtime, 3, 1); | |
7247 } | 7246 } |
7248 | 7247 |
7249 | 7248 |
7250 // NOTE: The stub does not handle the inlined cases (Smis, Booleans, undefined). | 7249 // NOTE: The stub does not handle the inlined cases (Smis, Booleans, undefined). |
7251 void ToBooleanStub::Generate(MacroAssembler* masm) { | 7250 void ToBooleanStub::Generate(MacroAssembler* masm) { |
7252 Label false_result, true_result, not_string; | 7251 Label false_result, true_result, not_string; |
7253 __ mov(eax, Operand(esp, 1 * kPointerSize)); | 7252 __ mov(eax, Operand(esp, 1 * kPointerSize)); |
7254 | 7253 |
7255 // 'null' => false. | 7254 // 'null' => false. |
7256 __ cmp(eax, Factory::null_value()); | 7255 __ cmp(eax, Factory::null_value()); |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8646 __ neg(edx); | 8645 __ neg(edx); |
8647 __ mov(eax, Operand(ebx, edx, times_2, kDisplacement)); | 8646 __ mov(eax, Operand(ebx, edx, times_2, kDisplacement)); |
8648 __ ret(0); | 8647 __ ret(0); |
8649 | 8648 |
8650 // Slow-case: Handle non-smi or out-of-bounds access to arguments | 8649 // Slow-case: Handle non-smi or out-of-bounds access to arguments |
8651 // by calling the runtime system. | 8650 // by calling the runtime system. |
8652 __ bind(&slow); | 8651 __ bind(&slow); |
8653 __ pop(ebx); // Return address. | 8652 __ pop(ebx); // Return address. |
8654 __ push(edx); | 8653 __ push(edx); |
8655 __ push(ebx); | 8654 __ push(ebx); |
8656 __ TailCallRuntime(ExternalReference(Runtime::kGetArgumentsProperty), 1, 1); | 8655 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1); |
8657 } | 8656 } |
8658 | 8657 |
8659 | 8658 |
8660 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { | 8659 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { |
8661 // esp[0] : return address | 8660 // esp[0] : return address |
8662 // esp[4] : number of parameters | 8661 // esp[4] : number of parameters |
8663 // esp[8] : receiver displacement | 8662 // esp[8] : receiver displacement |
8664 // esp[16] : function | 8663 // esp[16] : function |
8665 | 8664 |
8666 // The displacement is used for skipping the return address and the | 8665 // The displacement is used for skipping the return address and the |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8747 __ sub(Operand(edx), Immediate(kPointerSize)); | 8746 __ sub(Operand(edx), Immediate(kPointerSize)); |
8748 __ dec(ecx); | 8747 __ dec(ecx); |
8749 __ j(not_zero, &loop); | 8748 __ j(not_zero, &loop); |
8750 | 8749 |
8751 // Return and remove the on-stack parameters. | 8750 // Return and remove the on-stack parameters. |
8752 __ bind(&done); | 8751 __ bind(&done); |
8753 __ ret(3 * kPointerSize); | 8752 __ ret(3 * kPointerSize); |
8754 | 8753 |
8755 // Do the runtime call to allocate the arguments object. | 8754 // Do the runtime call to allocate the arguments object. |
8756 __ bind(&runtime); | 8755 __ bind(&runtime); |
8757 __ TailCallRuntime(ExternalReference(Runtime::kNewArgumentsFast), 3, 1); | 8756 __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1); |
8758 } | 8757 } |
8759 | 8758 |
8760 | 8759 |
8761 void RegExpExecStub::Generate(MacroAssembler* masm) { | 8760 void RegExpExecStub::Generate(MacroAssembler* masm) { |
8762 // Just jump directly to runtime if native RegExp is not selected at compile | 8761 // Just jump directly to runtime if native RegExp is not selected at compile |
8763 // time or if regexp entry in generated code is turned off runtime switch or | 8762 // time or if regexp entry in generated code is turned off runtime switch or |
8764 // at compilation. | 8763 // at compilation. |
8765 #ifndef V8_NATIVE_REGEXP | 8764 #ifndef V8_NATIVE_REGEXP |
8766 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); | 8765 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); |
8767 #else // V8_NATIVE_REGEXP | 8766 #else // V8_NATIVE_REGEXP |
8768 if (!FLAG_regexp_entry_native) { | 8767 if (!FLAG_regexp_entry_native) { |
8769 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); | 8768 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); |
8770 return; | 8769 return; |
8771 } | 8770 } |
8772 | 8771 |
8773 // Stack frame on entry. | 8772 // Stack frame on entry. |
8774 // esp[0]: return address | 8773 // esp[0]: return address |
8775 // esp[4]: last_match_info (expected JSArray) | 8774 // esp[4]: last_match_info (expected JSArray) |
8776 // esp[8]: previous index | 8775 // esp[8]: previous index |
8777 // esp[12]: subject string | 8776 // esp[12]: subject string |
8778 // esp[16]: JSRegExp object | 8777 // esp[16]: JSRegExp object |
8779 | 8778 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9081 edi); | 9080 edi); |
9082 __ jmp(&next_capture); | 9081 __ jmp(&next_capture); |
9083 __ bind(&done); | 9082 __ bind(&done); |
9084 | 9083 |
9085 // Return last match info. | 9084 // Return last match info. |
9086 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 9085 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); |
9087 __ ret(4 * kPointerSize); | 9086 __ ret(4 * kPointerSize); |
9088 | 9087 |
9089 // Do the runtime call to execute the regexp. | 9088 // Do the runtime call to execute the regexp. |
9090 __ bind(&runtime); | 9089 __ bind(&runtime); |
9091 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); | 9090 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); |
9092 #endif // V8_NATIVE_REGEXP | 9091 #endif // V8_NATIVE_REGEXP |
9093 } | 9092 } |
9094 | 9093 |
9095 | 9094 |
9096 void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, | 9095 void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, |
9097 Register object, | 9096 Register object, |
9098 Register result, | 9097 Register result, |
9099 Register scratch1, | 9098 Register scratch1, |
9100 Register scratch2, | 9099 Register scratch2, |
9101 bool object_is_smi, | 9100 bool object_is_smi, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9150 Label runtime; | 9149 Label runtime; |
9151 | 9150 |
9152 __ mov(ebx, Operand(esp, kPointerSize)); | 9151 __ mov(ebx, Operand(esp, kPointerSize)); |
9153 | 9152 |
9154 // Generate code to lookup number in the number string cache. | 9153 // Generate code to lookup number in the number string cache. |
9155 GenerateLookupNumberStringCache(masm, ebx, eax, ecx, edx, false, &runtime); | 9154 GenerateLookupNumberStringCache(masm, ebx, eax, ecx, edx, false, &runtime); |
9156 __ ret(1 * kPointerSize); | 9155 __ ret(1 * kPointerSize); |
9157 | 9156 |
9158 __ bind(&runtime); | 9157 __ bind(&runtime); |
9159 // Handle number to string in the runtime system if not found in the cache. | 9158 // Handle number to string in the runtime system if not found in the cache. |
9160 __ TailCallRuntime(ExternalReference(Runtime::kNumberToString), 1, 1); | 9159 __ TailCallRuntime(Runtime::kNumberToString, 1, 1); |
9161 } | 9160 } |
9162 | 9161 |
9163 | 9162 |
9164 void CompareStub::Generate(MacroAssembler* masm) { | 9163 void CompareStub::Generate(MacroAssembler* masm) { |
9165 Label call_builtin, done; | 9164 Label call_builtin, done; |
9166 | 9165 |
9167 // NOTICE! This code is only reached after a smi-fast-case check, so | 9166 // NOTICE! This code is only reached after a smi-fast-case check, so |
9168 // it is certain that at least one operand isn't a smi. | 9167 // it is certain that at least one operand isn't a smi. |
9169 | 9168 |
9170 if (cc_ == equal) { // Both strict and non-strict. | 9169 if (cc_ == equal) { // Both strict and non-strict. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9435 void StackCheckStub::Generate(MacroAssembler* masm) { | 9434 void StackCheckStub::Generate(MacroAssembler* masm) { |
9436 // Because builtins always remove the receiver from the stack, we | 9435 // Because builtins always remove the receiver from the stack, we |
9437 // have to fake one to avoid underflowing the stack. The receiver | 9436 // have to fake one to avoid underflowing the stack. The receiver |
9438 // must be inserted below the return address on the stack so we | 9437 // must be inserted below the return address on the stack so we |
9439 // temporarily store that in a register. | 9438 // temporarily store that in a register. |
9440 __ pop(eax); | 9439 __ pop(eax); |
9441 __ push(Immediate(Smi::FromInt(0))); | 9440 __ push(Immediate(Smi::FromInt(0))); |
9442 __ push(eax); | 9441 __ push(eax); |
9443 | 9442 |
9444 // Do tail-call to runtime routine. | 9443 // Do tail-call to runtime routine. |
9445 __ TailCallRuntime(ExternalReference(Runtime::kStackGuard), 1, 1); | 9444 __ TailCallRuntime(Runtime::kStackGuard, 1, 1); |
9446 } | 9445 } |
9447 | 9446 |
9448 | 9447 |
9449 void CallFunctionStub::Generate(MacroAssembler* masm) { | 9448 void CallFunctionStub::Generate(MacroAssembler* masm) { |
9450 Label slow; | 9449 Label slow; |
9451 | 9450 |
9452 // If the receiver might be a value (string, number or boolean) check for this | 9451 // If the receiver might be a value (string, number or boolean) check for this |
9453 // and box it if it is. | 9452 // and box it if it is. |
9454 if (ReceiverMightBeValue()) { | 9453 if (ReceiverMightBeValue()) { |
9455 // Get the receiver from the stack. | 9454 // Get the receiver from the stack. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9596 // It was zero; the result is undefined. | 9595 // It was zero; the result is undefined. |
9597 __ mov(eax, Factory::undefined_value()); | 9596 __ mov(eax, Factory::undefined_value()); |
9598 __ jmp(&prologue); | 9597 __ jmp(&prologue); |
9599 // It was non-zero. Dereference to get the result value. | 9598 // It was non-zero. Dereference to get the result value. |
9600 __ bind(&get_result); | 9599 __ bind(&get_result); |
9601 __ mov(eax, Operand(eax, 0)); | 9600 __ mov(eax, Operand(eax, 0)); |
9602 __ bind(&prologue); | 9601 __ bind(&prologue); |
9603 __ LeaveExitFrame(ExitFrame::MODE_NORMAL); | 9602 __ LeaveExitFrame(ExitFrame::MODE_NORMAL); |
9604 __ ret(0); | 9603 __ ret(0); |
9605 __ bind(&promote_scheduled_exception); | 9604 __ bind(&promote_scheduled_exception); |
9606 __ TailCallRuntime(ExternalReference(Runtime::kPromoteScheduledException), | 9605 __ TailCallRuntime(Runtime::kPromoteScheduledException, |
9607 0, | 9606 0, |
9608 1); | 9607 1); |
9609 } | 9608 } |
9610 | 9609 |
9611 | 9610 |
9612 void CEntryStub::GenerateCore(MacroAssembler* masm, | 9611 void CEntryStub::GenerateCore(MacroAssembler* masm, |
9613 Label* throw_normal_exception, | 9612 Label* throw_normal_exception, |
9614 Label* throw_termination_exception, | 9613 Label* throw_termination_exception, |
9615 Label* throw_out_of_memory_exception, | 9614 Label* throw_out_of_memory_exception, |
9616 bool do_gc, | 9615 bool do_gc, |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10227 // eax: result string | 10226 // eax: result string |
10228 // ecx: next character of result | 10227 // ecx: next character of result |
10229 // edx: first char of second argument | 10228 // edx: first char of second argument |
10230 // edi: length of second argument | 10229 // edi: length of second argument |
10231 GenerateCopyCharacters(masm, ecx, edx, edi, ebx, false); | 10230 GenerateCopyCharacters(masm, ecx, edx, edi, ebx, false); |
10232 __ IncrementCounter(&Counters::string_add_native, 1); | 10231 __ IncrementCounter(&Counters::string_add_native, 1); |
10233 __ ret(2 * kPointerSize); | 10232 __ ret(2 * kPointerSize); |
10234 | 10233 |
10235 // Just jump to runtime to add the two strings. | 10234 // Just jump to runtime to add the two strings. |
10236 __ bind(&string_add_runtime); | 10235 __ bind(&string_add_runtime); |
10237 __ TailCallRuntime(ExternalReference(Runtime::kStringAdd), 2, 1); | 10236 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
10238 } | 10237 } |
10239 | 10238 |
10240 | 10239 |
10241 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm, | 10240 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm, |
10242 Register dest, | 10241 Register dest, |
10243 Register src, | 10242 Register src, |
10244 Register count, | 10243 Register count, |
10245 Register scratch, | 10244 Register scratch, |
10246 bool ascii) { | 10245 bool ascii) { |
10247 Label loop; | 10246 Label loop; |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10637 // edx: original value of esi | 10636 // edx: original value of esi |
10638 // edi: first character of result | 10637 // edi: first character of result |
10639 // esi: character of sub string start | 10638 // esi: character of sub string start |
10640 GenerateCopyCharactersREP(masm, edi, esi, ecx, ebx, false); | 10639 GenerateCopyCharactersREP(masm, edi, esi, ecx, ebx, false); |
10641 __ mov(esi, edx); // Restore esi. | 10640 __ mov(esi, edx); // Restore esi. |
10642 __ IncrementCounter(&Counters::sub_string_native, 1); | 10641 __ IncrementCounter(&Counters::sub_string_native, 1); |
10643 __ ret(3 * kPointerSize); | 10642 __ ret(3 * kPointerSize); |
10644 | 10643 |
10645 // Just jump to runtime to create the sub string. | 10644 // Just jump to runtime to create the sub string. |
10646 __ bind(&runtime); | 10645 __ bind(&runtime); |
10647 __ TailCallRuntime(ExternalReference(Runtime::kSubString), 3, 1); | 10646 __ TailCallRuntime(Runtime::kSubString, 3, 1); |
10648 } | 10647 } |
10649 | 10648 |
10650 | 10649 |
10651 void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, | 10650 void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, |
10652 Register left, | 10651 Register left, |
10653 Register right, | 10652 Register right, |
10654 Register scratch1, | 10653 Register scratch1, |
10655 Register scratch2, | 10654 Register scratch2, |
10656 Register scratch3) { | 10655 Register scratch3) { |
10657 Label result_not_equal; | 10656 Label result_not_equal; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10753 // Check that both objects are sequential ascii strings. | 10752 // Check that both objects are sequential ascii strings. |
10754 __ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx, &runtime); | 10753 __ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx, &runtime); |
10755 | 10754 |
10756 // Compare flat ascii strings. | 10755 // Compare flat ascii strings. |
10757 __ IncrementCounter(&Counters::string_compare_native, 1); | 10756 __ IncrementCounter(&Counters::string_compare_native, 1); |
10758 GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi); | 10757 GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi); |
10759 | 10758 |
10760 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 10759 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
10761 // tagged as a small integer. | 10760 // tagged as a small integer. |
10762 __ bind(&runtime); | 10761 __ bind(&runtime); |
10763 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); | 10762 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
10764 } | 10763 } |
10765 | 10764 |
10766 #undef __ | 10765 #undef __ |
10767 | 10766 |
10768 } } // namespace v8::internal | 10767 } } // namespace v8::internal |
OLD | NEW |