OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 // -- rdi : target function (preserved for callee) | 991 // -- rdi : target function (preserved for callee) |
992 // ----------------------------------- | 992 // ----------------------------------- |
993 // First lookup code, maybe we don't need to compile! | 993 // First lookup code, maybe we don't need to compile! |
994 Label gotta_call_runtime; | 994 Label gotta_call_runtime; |
995 Label try_shared; | 995 Label try_shared; |
996 Label loop_top, loop_bottom; | 996 Label loop_top, loop_bottom; |
997 | 997 |
998 Register closure = rdi; | 998 Register closure = rdi; |
999 Register map = r8; | 999 Register map = r8; |
1000 Register index = r9; | 1000 Register index = r9; |
1001 | |
1002 // Do we have a valid feedback vector? | |
1003 __ movp(rbx, FieldOperand(closure, JSFunction::kLiteralsOffset)); | |
1004 __ movp(rbx, FieldOperand(rbx, LiteralsArray::kFeedbackVectorOffset)); | |
1005 __ JumpIfRoot(rbx, Heap::kUndefinedValueRootIndex, &gotta_call_runtime); | |
1006 | |
1007 __ movp(map, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1001 __ movp(map, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1008 __ movp(map, FieldOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | 1002 __ movp(map, FieldOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
1009 __ SmiToInteger32(index, FieldOperand(map, FixedArray::kLengthOffset)); | 1003 __ SmiToInteger32(index, FieldOperand(map, FixedArray::kLengthOffset)); |
1010 __ cmpl(index, Immediate(2)); | 1004 __ cmpl(index, Immediate(2)); |
1011 __ j(less, &gotta_call_runtime); | 1005 __ j(less, &gotta_call_runtime); |
1012 | 1006 |
| 1007 // Find literals. |
1013 // r14 : native context | 1008 // r14 : native context |
1014 // r9 : length / index | 1009 // r9 : length / index |
1015 // r8 : optimized code map | 1010 // r8 : optimized code map |
1016 // rdx : new target | 1011 // rdx : new target |
1017 // rdi : closure | 1012 // rdi : closure |
1018 Register native_context = r14; | 1013 Register native_context = r14; |
1019 __ movp(native_context, NativeContextOperand()); | 1014 __ movp(native_context, NativeContextOperand()); |
1020 | 1015 |
1021 __ bind(&loop_top); | 1016 __ bind(&loop_top); |
1022 // Native context match? | 1017 // Native context match? |
1023 Register temp = r11; | 1018 Register temp = r11; |
1024 __ movp(temp, FieldOperand(map, index, times_pointer_size, | 1019 __ movp(temp, FieldOperand(map, index, times_pointer_size, |
1025 SharedFunctionInfo::kOffsetToPreviousContext)); | 1020 SharedFunctionInfo::kOffsetToPreviousContext)); |
1026 __ movp(temp, FieldOperand(temp, WeakCell::kValueOffset)); | 1021 __ movp(temp, FieldOperand(temp, WeakCell::kValueOffset)); |
1027 __ cmpp(temp, native_context); | 1022 __ cmpp(temp, native_context); |
1028 __ j(not_equal, &loop_bottom); | 1023 __ j(not_equal, &loop_bottom); |
| 1024 // Literals available? |
| 1025 __ movp(temp, FieldOperand(map, index, times_pointer_size, |
| 1026 SharedFunctionInfo::kOffsetToPreviousLiterals)); |
| 1027 __ movp(temp, FieldOperand(temp, WeakCell::kValueOffset)); |
| 1028 __ JumpIfSmi(temp, &gotta_call_runtime); |
| 1029 |
| 1030 // Save the literals in the closure. |
| 1031 __ movp(FieldOperand(closure, JSFunction::kLiteralsOffset), temp); |
| 1032 __ movp(r15, index); |
| 1033 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, r15, |
| 1034 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
1029 | 1035 |
1030 // Code available? | 1036 // Code available? |
1031 Register entry = rcx; | 1037 Register entry = rcx; |
1032 __ movp(entry, FieldOperand(map, index, times_pointer_size, | 1038 __ movp(entry, FieldOperand(map, index, times_pointer_size, |
1033 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | 1039 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
1034 __ movp(entry, FieldOperand(entry, WeakCell::kValueOffset)); | 1040 __ movp(entry, FieldOperand(entry, WeakCell::kValueOffset)); |
1035 __ JumpIfSmi(entry, &try_shared); | 1041 __ JumpIfSmi(entry, &try_shared); |
1036 | 1042 |
1037 // Found code. Get it into the closure and return. | 1043 // Found literals and code. Get them into the closure and return. |
1038 __ leap(entry, FieldOperand(entry, Code::kHeaderSize)); | 1044 __ leap(entry, FieldOperand(entry, Code::kHeaderSize)); |
1039 __ movp(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry); | 1045 __ movp(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry); |
1040 __ RecordWriteCodeEntryField(closure, entry, r15); | 1046 __ RecordWriteCodeEntryField(closure, entry, r15); |
1041 | 1047 |
1042 // Link the closure into the optimized function list. | 1048 // Link the closure into the optimized function list. |
1043 // rcx : code entry (entry) | 1049 // rcx : code entry (entry) |
1044 // r14 : native context | 1050 // r14 : native context |
1045 // rdx : new target | 1051 // rdx : new target |
1046 // rdi : closure | 1052 // rdi : closure |
1047 __ movp(rbx, | 1053 __ movp(rbx, |
(...skipping 10 matching lines...) Expand all Loading... |
1058 __ RecordWriteContextSlot(native_context, function_list_offset, closure, r15, | 1064 __ RecordWriteContextSlot(native_context, function_list_offset, closure, r15, |
1059 kDontSaveFPRegs); | 1065 kDontSaveFPRegs); |
1060 __ movp(closure, rbx); | 1066 __ movp(closure, rbx); |
1061 __ jmp(entry); | 1067 __ jmp(entry); |
1062 | 1068 |
1063 __ bind(&loop_bottom); | 1069 __ bind(&loop_bottom); |
1064 __ subl(index, Immediate(SharedFunctionInfo::kEntryLength)); | 1070 __ subl(index, Immediate(SharedFunctionInfo::kEntryLength)); |
1065 __ cmpl(index, Immediate(1)); | 1071 __ cmpl(index, Immediate(1)); |
1066 __ j(greater, &loop_top); | 1072 __ j(greater, &loop_top); |
1067 | 1073 |
1068 // We found no code. | 1074 // We found neither literals nor code. |
1069 __ jmp(&gotta_call_runtime); | 1075 __ jmp(&gotta_call_runtime); |
1070 | 1076 |
1071 __ bind(&try_shared); | 1077 __ bind(&try_shared); |
1072 __ movp(entry, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1078 __ movp(entry, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1073 // Is the shared function marked for tier up? | 1079 // Is the shared function marked for tier up? |
1074 __ testb(FieldOperand(entry, SharedFunctionInfo::kMarkedForTierUpByteOffset), | 1080 __ testb(FieldOperand(entry, SharedFunctionInfo::kMarkedForTierUpByteOffset), |
1075 Immediate(1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte)); | 1081 Immediate(1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte)); |
1076 __ j(not_zero, &gotta_call_runtime); | 1082 __ j(not_zero, &gotta_call_runtime); |
1077 | 1083 |
1078 // If SFI points to anything other than CompileLazy, install that. | 1084 // If SFI points to anything other than CompileLazy, install that. |
(...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3176 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3182 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3177 Generate_OnStackReplacementHelper(masm, true); | 3183 Generate_OnStackReplacementHelper(masm, true); |
3178 } | 3184 } |
3179 | 3185 |
3180 #undef __ | 3186 #undef __ |
3181 | 3187 |
3182 } // namespace internal | 3188 } // namespace internal |
3183 } // namespace v8 | 3189 } // namespace v8 |
3184 | 3190 |
3185 #endif // V8_TARGET_ARCH_X64 | 3191 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |