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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 | 1061 |
1062 | 1062 |
1063 void MacroAssembler::PopTryHandler() { | 1063 void MacroAssembler::PopTryHandler() { |
1064 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 1064 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
1065 ExternalReference handler_address(Isolate::kHandlerAddress, isolate()); | 1065 ExternalReference handler_address(Isolate::kHandlerAddress, isolate()); |
1066 pop(Operand::StaticVariable(handler_address)); | 1066 pop(Operand::StaticVariable(handler_address)); |
1067 add(esp, Immediate(StackHandlerConstants::kSize - kPointerSize)); | 1067 add(esp, Immediate(StackHandlerConstants::kSize - kPointerSize)); |
1068 } | 1068 } |
1069 | 1069 |
1070 | 1070 |
1071 void MacroAssembler::JumpToHandlerEntry() { | |
1072 // Compute the handler entry address and jump to it. The handler table is | |
1073 // a fixed array of (smi-tagged) code offsets. | |
1074 // eax = exception, edi = code object, edx = state. | |
1075 mov(ebx, FieldOperand(edi, Code::kHandlerTableOffset)); | |
1076 shr(edx, StackHandler::kKindWidth); | |
1077 mov(edx, FieldOperand(ebx, edx, times_4, FixedArray::kHeaderSize)); | |
1078 SmiUntag(edx); | |
1079 lea(edi, FieldOperand(edi, edx, times_1, Code::kHeaderSize)); | |
1080 jmp(edi); | |
1081 } | |
1082 | |
1083 | |
1084 void MacroAssembler::Throw(Register value) { | |
1085 // Adjust this code if not the case. | |
1086 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | |
1087 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | |
1088 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | |
1089 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | |
1090 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | |
1091 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | |
1092 | |
1093 // The exception is expected in eax. | |
1094 if (!value.is(eax)) { | |
1095 mov(eax, value); | |
1096 } | |
1097 // Drop the stack pointer to the top of the top handler. | |
1098 ExternalReference handler_address(Isolate::kHandlerAddress, isolate()); | |
1099 mov(esp, Operand::StaticVariable(handler_address)); | |
1100 // Restore the next handler. | |
1101 pop(Operand::StaticVariable(handler_address)); | |
1102 | |
1103 // Remove the code object and state, compute the handler address in edi. | |
1104 pop(edi); // Code object. | |
1105 pop(edx); // Index and state. | |
1106 | |
1107 // Restore the context and frame pointer. | |
1108 pop(esi); // Context. | |
1109 pop(ebp); // Frame pointer. | |
1110 | |
1111 // If the handler is a JS frame, restore the context to the frame. | |
1112 // (kind == ENTRY) == (ebp == 0) == (esi == 0), so we could test either | |
1113 // ebp or esi. | |
1114 Label skip; | |
1115 test(esi, esi); | |
1116 j(zero, &skip, Label::kNear); | |
1117 mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi); | |
1118 bind(&skip); | |
1119 | |
1120 JumpToHandlerEntry(); | |
1121 } | |
1122 | |
1123 | |
1124 void MacroAssembler::ThrowUncatchable(Register value) { | |
1125 // Adjust this code if not the case. | |
1126 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | |
1127 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | |
1128 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | |
1129 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | |
1130 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | |
1131 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | |
1132 | |
1133 // The exception is expected in eax. | |
1134 if (!value.is(eax)) { | |
1135 mov(eax, value); | |
1136 } | |
1137 // Drop the stack pointer to the top of the top stack handler. | |
1138 ExternalReference handler_address(Isolate::kHandlerAddress, isolate()); | |
1139 mov(esp, Operand::StaticVariable(handler_address)); | |
1140 | |
1141 // Unwind the handlers until the top ENTRY handler is found. | |
1142 Label fetch_next, check_kind; | |
1143 jmp(&check_kind, Label::kNear); | |
1144 bind(&fetch_next); | |
1145 mov(esp, Operand(esp, StackHandlerConstants::kNextOffset)); | |
1146 | |
1147 bind(&check_kind); | |
1148 STATIC_ASSERT(StackHandler::JS_ENTRY == 0); | |
1149 test(Operand(esp, StackHandlerConstants::kStateOffset), | |
1150 Immediate(StackHandler::KindField::kMask)); | |
1151 j(not_zero, &fetch_next); | |
1152 | |
1153 // Set the top handler address to next handler past the top ENTRY handler. | |
1154 pop(Operand::StaticVariable(handler_address)); | |
1155 | |
1156 // Remove the code object and state, compute the handler address in edi. | |
1157 pop(edi); // Code object. | |
1158 pop(edx); // Index and state. | |
1159 | |
1160 // Clear the context pointer and frame pointer (0 was saved in the handler). | |
1161 pop(esi); | |
1162 pop(ebp); | |
1163 | |
1164 JumpToHandlerEntry(); | |
1165 } | |
1166 | |
1167 | |
1168 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, | 1071 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, |
1169 Register scratch1, | 1072 Register scratch1, |
1170 Register scratch2, | 1073 Register scratch2, |
1171 Label* miss) { | 1074 Label* miss) { |
1172 Label same_contexts; | 1075 Label same_contexts; |
1173 | 1076 |
1174 DCHECK(!holder_reg.is(scratch1)); | 1077 DCHECK(!holder_reg.is(scratch1)); |
1175 DCHECK(!holder_reg.is(scratch2)); | 1078 DCHECK(!holder_reg.is(scratch2)); |
1176 DCHECK(!scratch1.is(scratch2)); | 1079 DCHECK(!scratch1.is(scratch2)); |
1177 | 1080 |
(...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 if (mag.shift > 0) sar(edx, mag.shift); | 3200 if (mag.shift > 0) sar(edx, mag.shift); |
3298 mov(eax, dividend); | 3201 mov(eax, dividend); |
3299 shr(eax, 31); | 3202 shr(eax, 31); |
3300 add(edx, eax); | 3203 add(edx, eax); |
3301 } | 3204 } |
3302 | 3205 |
3303 | 3206 |
3304 } } // namespace v8::internal | 3207 } } // namespace v8::internal |
3305 | 3208 |
3306 #endif // V8_TARGET_ARCH_IA32 | 3209 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |