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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 // ----------------------------------- | 1021 // ----------------------------------- |
1022 // First lookup code, maybe we don't need to compile! | 1022 // First lookup code, maybe we don't need to compile! |
1023 Label gotta_call_runtime, gotta_call_runtime_no_stack; | 1023 Label gotta_call_runtime, gotta_call_runtime_no_stack; |
1024 Label try_shared; | 1024 Label try_shared; |
1025 Label loop_top, loop_bottom; | 1025 Label loop_top, loop_bottom; |
1026 | 1026 |
1027 Register closure = edi; | 1027 Register closure = edi; |
1028 Register new_target = edx; | 1028 Register new_target = edx; |
1029 Register argument_count = eax; | 1029 Register argument_count = eax; |
1030 | 1030 |
| 1031 // Do we have a valid feedback vector? |
| 1032 __ mov(ebx, FieldOperand(closure, JSFunction::kFeedbackVectorOffset)); |
| 1033 __ mov(ebx, FieldOperand(ebx, Cell::kValueOffset)); |
| 1034 __ JumpIfRoot(ebx, Heap::kUndefinedValueRootIndex, |
| 1035 &gotta_call_runtime_no_stack); |
| 1036 |
1031 __ push(argument_count); | 1037 __ push(argument_count); |
1032 __ push(new_target); | 1038 __ push(new_target); |
1033 __ push(closure); | 1039 __ push(closure); |
1034 | 1040 |
1035 Register map = argument_count; | 1041 Register map = argument_count; |
1036 Register index = ebx; | 1042 Register index = ebx; |
1037 __ mov(map, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1043 __ mov(map, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1038 __ mov(map, FieldOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | 1044 __ mov(map, FieldOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
1039 __ mov(index, FieldOperand(map, FixedArray::kLengthOffset)); | 1045 __ mov(index, FieldOperand(map, FixedArray::kLengthOffset)); |
1040 __ cmp(index, Immediate(Smi::FromInt(2))); | 1046 __ cmp(index, Immediate(Smi::FromInt(2))); |
1041 __ j(less, &gotta_call_runtime); | 1047 __ j(less, &try_shared); |
1042 | 1048 |
1043 // Find literals. | |
1044 // edx : native context | 1049 // edx : native context |
1045 // ebx : length / index | 1050 // ebx : length / index |
1046 // eax : optimized code map | 1051 // eax : optimized code map |
1047 // stack[0] : new target | 1052 // stack[0] : new target |
1048 // stack[4] : closure | 1053 // stack[4] : closure |
1049 Register native_context = edx; | 1054 Register native_context = edx; |
1050 __ mov(native_context, NativeContextOperand()); | 1055 __ mov(native_context, NativeContextOperand()); |
1051 | 1056 |
1052 __ bind(&loop_top); | 1057 __ bind(&loop_top); |
1053 Register temp = edi; | 1058 Register temp = edi; |
1054 | 1059 |
1055 // Does the native context match? | 1060 // Does the native context match? |
1056 __ mov(temp, FieldOperand(map, index, times_half_pointer_size, | 1061 __ mov(temp, FieldOperand(map, index, times_half_pointer_size, |
1057 SharedFunctionInfo::kOffsetToPreviousContext)); | 1062 SharedFunctionInfo::kOffsetToPreviousContext)); |
1058 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset)); | 1063 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset)); |
1059 __ cmp(temp, native_context); | 1064 __ cmp(temp, native_context); |
1060 __ j(not_equal, &loop_bottom); | 1065 __ j(not_equal, &loop_bottom); |
1061 // Feedback vector available? | |
1062 __ mov(temp, FieldOperand(map, index, times_half_pointer_size, | |
1063 SharedFunctionInfo::kOffsetToPreviousLiterals)); | |
1064 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset)); | |
1065 __ JumpIfSmi(temp, &gotta_call_runtime); | |
1066 | |
1067 // Save the vector in the closure. | |
1068 __ mov(ecx, Operand(esp, 0)); | |
1069 __ mov(FieldOperand(ecx, JSFunction::kFeedbackVectorOffset), temp); | |
1070 __ push(index); | |
1071 __ RecordWriteField(ecx, JSFunction::kFeedbackVectorOffset, temp, index, | |
1072 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | |
1073 __ pop(index); | |
1074 | 1066 |
1075 // Code available? | 1067 // Code available? |
1076 Register entry = ecx; | 1068 Register entry = ecx; |
1077 __ mov(entry, FieldOperand(map, index, times_half_pointer_size, | 1069 __ mov(entry, FieldOperand(map, index, times_half_pointer_size, |
1078 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | 1070 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
1079 __ mov(entry, FieldOperand(entry, WeakCell::kValueOffset)); | 1071 __ mov(entry, FieldOperand(entry, WeakCell::kValueOffset)); |
1080 __ JumpIfSmi(entry, &try_shared); | 1072 __ JumpIfSmi(entry, &try_shared); |
1081 | 1073 |
1082 // Found literals and code. Get them into the closure and return. | 1074 // Found code. Get it into the closure and return. |
1083 __ pop(closure); | 1075 __ pop(closure); |
1084 // Store code entry in the closure. | 1076 // Store code entry in the closure. |
1085 __ lea(entry, FieldOperand(entry, Code::kHeaderSize)); | 1077 __ lea(entry, FieldOperand(entry, Code::kHeaderSize)); |
1086 __ mov(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry); | 1078 __ mov(FieldOperand(closure, JSFunction::kCodeEntryOffset), entry); |
1087 __ RecordWriteCodeEntryField(closure, entry, eax); | 1079 __ RecordWriteCodeEntryField(closure, entry, eax); |
1088 | 1080 |
1089 // Link the closure into the optimized function list. | 1081 // Link the closure into the optimized function list. |
1090 // ecx : code entry | 1082 // ecx : code entry |
1091 // edx : native context | 1083 // edx : native context |
1092 // edi : closure | 1084 // edi : closure |
(...skipping 13 matching lines...) Expand all Loading... |
1106 __ mov(closure, ebx); | 1098 __ mov(closure, ebx); |
1107 __ pop(new_target); | 1099 __ pop(new_target); |
1108 __ pop(argument_count); | 1100 __ pop(argument_count); |
1109 __ jmp(entry); | 1101 __ jmp(entry); |
1110 | 1102 |
1111 __ bind(&loop_bottom); | 1103 __ bind(&loop_bottom); |
1112 __ sub(index, Immediate(Smi::FromInt(SharedFunctionInfo::kEntryLength))); | 1104 __ sub(index, Immediate(Smi::FromInt(SharedFunctionInfo::kEntryLength))); |
1113 __ cmp(index, Immediate(Smi::FromInt(1))); | 1105 __ cmp(index, Immediate(Smi::FromInt(1))); |
1114 __ j(greater, &loop_top); | 1106 __ j(greater, &loop_top); |
1115 | 1107 |
1116 // We found neither literals nor code. | 1108 // We found no code. |
1117 __ jmp(&gotta_call_runtime); | |
1118 | |
1119 __ bind(&try_shared); | 1109 __ bind(&try_shared); |
1120 __ pop(closure); | 1110 __ pop(closure); |
1121 __ pop(new_target); | 1111 __ pop(new_target); |
1122 __ pop(argument_count); | 1112 __ pop(argument_count); |
1123 __ mov(entry, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1113 __ mov(entry, FieldOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1124 // Is the shared function marked for tier up? | 1114 // Is the shared function marked for tier up? |
1125 __ test_b(FieldOperand(entry, SharedFunctionInfo::kMarkedForTierUpByteOffset), | 1115 __ test_b(FieldOperand(entry, SharedFunctionInfo::kMarkedForTierUpByteOffset), |
1126 Immediate(1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte)); | 1116 Immediate(1 << SharedFunctionInfo::kMarkedForTierUpBitWithinByte)); |
1127 __ j(not_zero, &gotta_call_runtime_no_stack); | 1117 __ j(not_zero, &gotta_call_runtime_no_stack); |
1128 | 1118 |
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3373 | 3363 |
3374 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3364 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3375 Generate_OnStackReplacementHelper(masm, true); | 3365 Generate_OnStackReplacementHelper(masm, true); |
3376 } | 3366 } |
3377 | 3367 |
3378 #undef __ | 3368 #undef __ |
3379 } // namespace internal | 3369 } // namespace internal |
3380 } // namespace v8 | 3370 } // namespace v8 |
3381 | 3371 |
3382 #endif // V8_TARGET_ARCH_IA32 | 3372 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |