| 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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 // -- rdi : target function (preserved for callee) | 987 // -- rdi : target function (preserved for callee) |
| 988 // ----------------------------------- | 988 // ----------------------------------- |
| 989 // First lookup code, maybe we don't need to compile! | 989 // First lookup code, maybe we don't need to compile! |
| 990 Label gotta_call_runtime; | 990 Label gotta_call_runtime; |
| 991 Label try_shared; | 991 Label try_shared; |
| 992 Label loop_top, loop_bottom; | 992 Label loop_top, loop_bottom; |
| 993 | 993 |
| 994 Register closure = rdi; | 994 Register closure = rdi; |
| 995 Register map = r8; | 995 Register map = r8; |
| 996 Register index = r9; | 996 Register index = r9; |
| 997 |
| 998 // Do we have a valid feedback vector? |
| 999 __ movp(rbx, FieldOperand(closure, JSFunction::kLiteralsOffset)); |
| 1000 __ movp(rbx, FieldOperand(rbx, LiteralsArray::kFeedbackVectorOffset)); |
| 1001 __ JumpIfRoot(rbx, Heap::kUndefinedValueRootIndex, &gotta_call_runtime); |
| 1002 |
| 997 __ movp(map, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1003 __ movp(map, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 998 __ movp(map, FieldOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | 1004 __ movp(map, FieldOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 999 __ SmiToInteger32(index, FieldOperand(map, FixedArray::kLengthOffset)); | 1005 __ SmiToInteger32(index, FieldOperand(map, FixedArray::kLengthOffset)); |
| 1000 __ cmpl(index, Immediate(2)); | 1006 __ cmpl(index, Immediate(2)); |
| 1001 __ j(less, &gotta_call_runtime); | 1007 __ j(less, &gotta_call_runtime); |
| 1002 | 1008 |
| 1003 // Find literals. | |
| 1004 // r14 : native context | 1009 // r14 : native context |
| 1005 // r9 : length / index | 1010 // r9 : length / index |
| 1006 // r8 : optimized code map | 1011 // r8 : optimized code map |
| 1007 // rdx : new target | 1012 // rdx : new target |
| 1008 // rdi : closure | 1013 // rdi : closure |
| 1009 Register native_context = r14; | 1014 Register native_context = r14; |
| 1010 __ movp(native_context, NativeContextOperand()); | 1015 __ movp(native_context, NativeContextOperand()); |
| 1011 | 1016 |
| 1012 __ bind(&loop_top); | 1017 __ bind(&loop_top); |
| 1013 // Native context match? | 1018 // Native context match? |
| 1014 Register temp = r11; | 1019 Register temp = r11; |
| 1015 __ movp(temp, FieldOperand(map, index, times_pointer_size, | 1020 __ movp(temp, FieldOperand(map, index, times_pointer_size, |
| 1016 SharedFunctionInfo::kOffsetToPreviousContext)); | 1021 SharedFunctionInfo::kOffsetToPreviousContext)); |
| 1017 __ movp(temp, FieldOperand(temp, WeakCell::kValueOffset)); | 1022 __ movp(temp, FieldOperand(temp, WeakCell::kValueOffset)); |
| 1018 __ cmpp(temp, native_context); | 1023 __ cmpp(temp, native_context); |
| 1019 __ j(not_equal, &loop_bottom); | 1024 __ j(not_equal, &loop_bottom); |
| 1020 // Literals available? | |
| 1021 __ movp(temp, FieldOperand(map, index, times_pointer_size, | |
| 1022 SharedFunctionInfo::kOffsetToPreviousLiterals)); | |
| 1023 __ movp(temp, FieldOperand(temp, WeakCell::kValueOffset)); | |
| 1024 __ JumpIfSmi(temp, &gotta_call_runtime); | |
| 1025 | |
| 1026 // Save the literals in the closure. | |
| 1027 __ movp(FieldOperand(closure, JSFunction::kLiteralsOffset), temp); | |
| 1028 __ movp(r15, index); | |
| 1029 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, r15, | |
| 1030 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | |
| 1031 | 1025 |
| 1032 // Code available? | 1026 // Code available? |
| 1033 Register entry = rcx; | 1027 Register entry = rcx; |
| 1034 __ movp(entry, FieldOperand(map, index, times_pointer_size, | 1028 __ movp(entry, FieldOperand(map, index, times_pointer_size, |
| 1035 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | 1029 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
| 1036 __ movp(entry, FieldOperand(entry, WeakCell::kValueOffset)); | 1030 __ movp(entry, FieldOperand(entry, WeakCell::kValueOffset)); |
| 1037 __ JumpIfSmi(entry, &try_shared); | 1031 __ JumpIfSmi(entry, &try_shared); |
| 1038 | 1032 |
| 1039 // Found literals and code. Get them into the closure and return. | 1033 // Found code. Get it into the closure and return. |
| 1040 __ leap(entry, FieldOperand(entry, Code::kHeaderSize)); | 1034 __ leap(entry, FieldOperand(entry, Code::kHeaderSize)); |
| 1041 __ movp(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry); | 1035 __ movp(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry); |
| 1042 __ RecordWriteCodeEntryField(closure, entry, r15); | 1036 __ RecordWriteCodeEntryField(closure, entry, r15); |
| 1043 | 1037 |
| 1044 // Link the closure into the optimized function list. | 1038 // Link the closure into the optimized function list. |
| 1045 // rcx : code entry (entry) | 1039 // rcx : code entry (entry) |
| 1046 // r14 : native context | 1040 // r14 : native context |
| 1047 // rdx : new target | 1041 // rdx : new target |
| 1048 // rdi : closure | 1042 // rdi : closure |
| 1049 __ movp(rbx, | 1043 __ movp(rbx, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1060 __ RecordWriteContextSlot(native_context, function_list_offset, closure, r15, | 1054 __ RecordWriteContextSlot(native_context, function_list_offset, closure, r15, |
| 1061 kDontSaveFPRegs); | 1055 kDontSaveFPRegs); |
| 1062 __ movp(closure, rbx); | 1056 __ movp(closure, rbx); |
| 1063 __ jmp(entry); | 1057 __ jmp(entry); |
| 1064 | 1058 |
| 1065 __ bind(&loop_bottom); | 1059 __ bind(&loop_bottom); |
| 1066 __ subl(index, Immediate(SharedFunctionInfo::kEntryLength)); | 1060 __ subl(index, Immediate(SharedFunctionInfo::kEntryLength)); |
| 1067 __ cmpl(index, Immediate(1)); | 1061 __ cmpl(index, Immediate(1)); |
| 1068 __ j(greater, &loop_top); | 1062 __ j(greater, &loop_top); |
| 1069 | 1063 |
| 1070 // We found neither literals nor code. | 1064 // We found no code. |
| 1071 __ jmp(&gotta_call_runtime); | 1065 __ jmp(&gotta_call_runtime); |
| 1072 | 1066 |
| 1073 __ bind(&try_shared); | 1067 __ bind(&try_shared); |
| 1074 __ movp(entry, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1068 __ movp(entry, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1075 // Is the shared function marked for tier up? | 1069 // Is the shared function marked for tier up? |
| 1076 __ testb(FieldOperand(entry, SharedFunctionInfo::kMarkedForTierUpByteOffset), | 1070 __ testb(FieldOperand(entry, SharedFunctionInfo::kMarkedForTierUpByteOffset), |
| 1077 Immediate(1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte)); | 1071 Immediate(1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte)); |
| 1078 __ j(not_zero, &gotta_call_runtime); | 1072 __ j(not_zero, &gotta_call_runtime); |
| 1079 | 1073 |
| 1080 // If SFI points to anything other than CompileLazy, install that. | 1074 // If SFI points to anything other than CompileLazy, install that. |
| (...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3046 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3040 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
| 3047 Generate_OnStackReplacementHelper(masm, true); | 3041 Generate_OnStackReplacementHelper(masm, true); |
| 3048 } | 3042 } |
| 3049 | 3043 |
| 3050 #undef __ | 3044 #undef __ |
| 3051 | 3045 |
| 3052 } // namespace internal | 3046 } // namespace internal |
| 3053 } // namespace v8 | 3047 } // namespace v8 |
| 3054 | 3048 |
| 3055 #endif // V8_TARGET_ARCH_X64 | 3049 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |