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