| 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 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 5 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| 6 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 6 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| 7 | 7 |
| 8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/frames.h" | 10 #include "src/frames.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // distinguish memory operands from other operands on ia32. | 34 // distinguish memory operands from other operands on ia32. |
| 35 typedef Operand MemOperand; | 35 typedef Operand MemOperand; |
| 36 | 36 |
| 37 enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; | 37 enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; |
| 38 enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; | 38 enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; |
| 39 enum PointersToHereCheck { | 39 enum PointersToHereCheck { |
| 40 kPointersToHereMaybeInteresting, | 40 kPointersToHereMaybeInteresting, |
| 41 kPointersToHereAreAlwaysInteresting | 41 kPointersToHereAreAlwaysInteresting |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 | 44 enum RegisterValueType { REGISTER_VALUE_IS_SMI, REGISTER_VALUE_IS_INT32 }; |
| 45 enum RegisterValueType { | |
| 46 REGISTER_VALUE_IS_SMI, | |
| 47 REGISTER_VALUE_IS_INT32 | |
| 48 }; | |
| 49 | |
| 50 | 45 |
| 51 #ifdef DEBUG | 46 #ifdef DEBUG |
| 52 bool AreAliased(Register reg1, | 47 bool AreAliased(Register reg1, Register reg2, Register reg3 = no_reg, |
| 53 Register reg2, | 48 Register reg4 = no_reg, Register reg5 = no_reg, |
| 54 Register reg3 = no_reg, | 49 Register reg6 = no_reg, Register reg7 = no_reg, |
| 55 Register reg4 = no_reg, | |
| 56 Register reg5 = no_reg, | |
| 57 Register reg6 = no_reg, | |
| 58 Register reg7 = no_reg, | |
| 59 Register reg8 = no_reg); | 50 Register reg8 = no_reg); |
| 60 #endif | 51 #endif |
| 61 | 52 |
| 62 | |
| 63 // MacroAssembler implements a collection of frequently used macros. | 53 // MacroAssembler implements a collection of frequently used macros. |
| 64 class MacroAssembler: public Assembler { | 54 class MacroAssembler: public Assembler { |
| 65 public: | 55 public: |
| 66 // The isolate parameter can be NULL if the macro assembler should | 56 // The isolate parameter can be NULL if the macro assembler should |
| 67 // not use isolate-dependent functionality. In this case, it's the | 57 // not use isolate-dependent functionality. In this case, it's the |
| 68 // responsibility of the caller to never invoke such function on the | 58 // responsibility of the caller to never invoke such function on the |
| 69 // macro assembler. | 59 // macro assembler. |
| 70 MacroAssembler(Isolate* isolate, void* buffer, int size); | 60 MacroAssembler(Isolate* isolate, void* buffer, int size); |
| 71 | 61 |
| 72 void Load(Register dst, const Operand& src, Representation r); | 62 void Load(Register dst, const Operand& src, Representation r); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 102 // Compare the object in a register to a value and jump if they are not equal. | 92 // Compare the object in a register to a value and jump if they are not equal. |
| 103 void JumpIfNotRoot(Register with, Heap::RootListIndex index, | 93 void JumpIfNotRoot(Register with, Heap::RootListIndex index, |
| 104 Label* if_not_equal, | 94 Label* if_not_equal, |
| 105 Label::Distance if_not_equal_distance = Label::kNear) { | 95 Label::Distance if_not_equal_distance = Label::kNear) { |
| 106 CompareRoot(with, index); | 96 CompareRoot(with, index); |
| 107 j(not_equal, if_not_equal, if_not_equal_distance); | 97 j(not_equal, if_not_equal, if_not_equal_distance); |
| 108 } | 98 } |
| 109 | 99 |
| 110 // --------------------------------------------------------------------------- | 100 // --------------------------------------------------------------------------- |
| 111 // GC Support | 101 // GC Support |
| 112 enum RememberedSetFinalAction { | 102 enum RememberedSetFinalAction { kReturnAtEnd, kFallThroughAtEnd }; |
| 113 kReturnAtEnd, | |
| 114 kFallThroughAtEnd | |
| 115 }; | |
| 116 | 103 |
| 117 // Record in the remembered set the fact that we have a pointer to new space | 104 // Record in the remembered set the fact that we have a pointer to new space |
| 118 // at the address pointed to by the addr register. Only works if addr is not | 105 // at the address pointed to by the addr register. Only works if addr is not |
| 119 // in new space. | 106 // in new space. |
| 120 void RememberedSetHelper(Register object, // Used for debug code. | 107 void RememberedSetHelper(Register object, // Used for debug code. |
| 121 Register addr, | 108 Register addr, Register scratch, |
| 122 Register scratch, | |
| 123 SaveFPRegsMode save_fp, | 109 SaveFPRegsMode save_fp, |
| 124 RememberedSetFinalAction and_then); | 110 RememberedSetFinalAction and_then); |
| 125 | 111 |
| 126 void CheckPageFlag(Register object, | 112 void CheckPageFlag(Register object, Register scratch, int mask, Condition cc, |
| 127 Register scratch, | |
| 128 int mask, | |
| 129 Condition cc, | |
| 130 Label* condition_met, | 113 Label* condition_met, |
| 131 Label::Distance condition_met_distance = Label::kFar); | 114 Label::Distance condition_met_distance = Label::kFar); |
| 132 | 115 |
| 133 void CheckPageFlagForMap( | 116 void CheckPageFlagForMap( |
| 134 Handle<Map> map, | 117 Handle<Map> map, int mask, Condition cc, Label* condition_met, |
| 135 int mask, | |
| 136 Condition cc, | |
| 137 Label* condition_met, | |
| 138 Label::Distance condition_met_distance = Label::kFar); | 118 Label::Distance condition_met_distance = Label::kFar); |
| 139 | 119 |
| 140 // Check if object is in new space. Jumps if the object is not in new space. | 120 // Check if object is in new space. Jumps if the object is not in new space. |
| 141 // The register scratch can be object itself, but scratch will be clobbered. | 121 // The register scratch can be object itself, but scratch will be clobbered. |
| 142 void JumpIfNotInNewSpace(Register object, | 122 void JumpIfNotInNewSpace(Register object, Register scratch, Label* branch, |
| 143 Register scratch, | |
| 144 Label* branch, | |
| 145 Label::Distance distance = Label::kFar) { | 123 Label::Distance distance = Label::kFar) { |
| 146 InNewSpace(object, scratch, zero, branch, distance); | 124 InNewSpace(object, scratch, zero, branch, distance); |
| 147 } | 125 } |
| 148 | 126 |
| 149 // Check if object is in new space. Jumps if the object is in new space. | 127 // Check if object is in new space. Jumps if the object is in new space. |
| 150 // The register scratch can be object itself, but it will be clobbered. | 128 // The register scratch can be object itself, but it will be clobbered. |
| 151 void JumpIfInNewSpace(Register object, | 129 void JumpIfInNewSpace(Register object, Register scratch, Label* branch, |
| 152 Register scratch, | |
| 153 Label* branch, | |
| 154 Label::Distance distance = Label::kFar) { | 130 Label::Distance distance = Label::kFar) { |
| 155 InNewSpace(object, scratch, not_zero, branch, distance); | 131 InNewSpace(object, scratch, not_zero, branch, distance); |
| 156 } | 132 } |
| 157 | 133 |
| 158 // Check if an object has a given incremental marking color. Also uses ecx! | 134 // Check if an object has a given incremental marking color. Also uses ecx! |
| 159 void HasColor(Register object, | 135 void HasColor(Register object, Register scratch0, Register scratch1, |
| 160 Register scratch0, | 136 Label* has_color, Label::Distance has_color_distance, |
| 161 Register scratch1, | 137 int first_bit, int second_bit); |
| 162 Label* has_color, | |
| 163 Label::Distance has_color_distance, | |
| 164 int first_bit, | |
| 165 int second_bit); | |
| 166 | 138 |
| 167 void JumpIfBlack(Register object, | 139 void JumpIfBlack(Register object, Register scratch0, Register scratch1, |
| 168 Register scratch0, | |
| 169 Register scratch1, | |
| 170 Label* on_black, | 140 Label* on_black, |
| 171 Label::Distance on_black_distance = Label::kFar); | 141 Label::Distance on_black_distance = Label::kFar); |
| 172 | 142 |
| 173 // Checks the color of an object. If the object is already grey or black | 143 // Checks the color of an object. If the object is already grey or black |
| 174 // then we just fall through, since it is already live. If it is white and | 144 // then we just fall through, since it is already live. If it is white and |
| 175 // we can determine that it doesn't need to be scanned, then we just mark it | 145 // we can determine that it doesn't need to be scanned, then we just mark it |
| 176 // black and fall through. For the rest we jump to the label so the | 146 // black and fall through. For the rest we jump to the label so the |
| 177 // incremental marker can fix its assumptions. | 147 // incremental marker can fix its assumptions. |
| 178 void EnsureNotWhite(Register object, | 148 void EnsureNotWhite(Register object, Register scratch1, Register scratch2, |
| 179 Register scratch1, | |
| 180 Register scratch2, | |
| 181 Label* object_is_white_and_not_data, | 149 Label* object_is_white_and_not_data, |
| 182 Label::Distance distance); | 150 Label::Distance distance); |
| 183 | 151 |
| 184 // Notify the garbage collector that we wrote a pointer into an object. | 152 // Notify the garbage collector that we wrote a pointer into an object. |
| 185 // |object| is the object being stored into, |value| is the object being | 153 // |object| is the object being stored into, |value| is the object being |
| 186 // stored. value and scratch registers are clobbered by the operation. | 154 // stored. value and scratch registers are clobbered by the operation. |
| 187 // The offset is the offset from the start of the object, not the offset from | 155 // The offset is the offset from the start of the object, not the offset from |
| 188 // the tagged HeapObject pointer. For use with FieldOperand(reg, off). | 156 // the tagged HeapObject pointer. For use with FieldOperand(reg, off). |
| 189 void RecordWriteField( | 157 void RecordWriteField( |
| 190 Register object, | 158 Register object, int offset, Register value, Register scratch, |
| 191 int offset, | |
| 192 Register value, | |
| 193 Register scratch, | |
| 194 SaveFPRegsMode save_fp, | 159 SaveFPRegsMode save_fp, |
| 195 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, | 160 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, |
| 196 SmiCheck smi_check = INLINE_SMI_CHECK, | 161 SmiCheck smi_check = INLINE_SMI_CHECK, |
| 197 PointersToHereCheck pointers_to_here_check_for_value = | 162 PointersToHereCheck pointers_to_here_check_for_value = |
| 198 kPointersToHereMaybeInteresting); | 163 kPointersToHereMaybeInteresting); |
| 199 | 164 |
| 200 // As above, but the offset has the tag presubtracted. For use with | 165 // As above, but the offset has the tag presubtracted. For use with |
| 201 // Operand(reg, off). | 166 // Operand(reg, off). |
| 202 void RecordWriteContextSlot( | 167 void RecordWriteContextSlot( |
| 203 Register context, | 168 Register context, int offset, Register value, Register scratch, |
| 204 int offset, | |
| 205 Register value, | |
| 206 Register scratch, | |
| 207 SaveFPRegsMode save_fp, | 169 SaveFPRegsMode save_fp, |
| 208 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, | 170 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, |
| 209 SmiCheck smi_check = INLINE_SMI_CHECK, | 171 SmiCheck smi_check = INLINE_SMI_CHECK, |
| 210 PointersToHereCheck pointers_to_here_check_for_value = | 172 PointersToHereCheck pointers_to_here_check_for_value = |
| 211 kPointersToHereMaybeInteresting) { | 173 kPointersToHereMaybeInteresting) { |
| 212 RecordWriteField(context, | 174 RecordWriteField(context, offset + kHeapObjectTag, value, scratch, save_fp, |
| 213 offset + kHeapObjectTag, | 175 remembered_set_action, smi_check, |
| 214 value, | |
| 215 scratch, | |
| 216 save_fp, | |
| 217 remembered_set_action, | |
| 218 smi_check, | |
| 219 pointers_to_here_check_for_value); | 176 pointers_to_here_check_for_value); |
| 220 } | 177 } |
| 221 | 178 |
| 222 // Notify the garbage collector that we wrote a pointer into a fixed array. | 179 // Notify the garbage collector that we wrote a pointer into a fixed array. |
| 223 // |array| is the array being stored into, |value| is the | 180 // |array| is the array being stored into, |value| is the |
| 224 // object being stored. |index| is the array index represented as a | 181 // object being stored. |index| is the array index represented as a |
| 225 // Smi. All registers are clobbered by the operation RecordWriteArray | 182 // Smi. All registers are clobbered by the operation RecordWriteArray |
| 226 // filters out smis so it does not update the write barrier if the | 183 // filters out smis so it does not update the write barrier if the |
| 227 // value is a smi. | 184 // value is a smi. |
| 228 void RecordWriteArray( | 185 void RecordWriteArray( |
| 229 Register array, | 186 Register array, Register value, Register index, SaveFPRegsMode save_fp, |
| 230 Register value, | |
| 231 Register index, | |
| 232 SaveFPRegsMode save_fp, | |
| 233 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, | 187 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, |
| 234 SmiCheck smi_check = INLINE_SMI_CHECK, | 188 SmiCheck smi_check = INLINE_SMI_CHECK, |
| 235 PointersToHereCheck pointers_to_here_check_for_value = | 189 PointersToHereCheck pointers_to_here_check_for_value = |
| 236 kPointersToHereMaybeInteresting); | 190 kPointersToHereMaybeInteresting); |
| 237 | 191 |
| 238 // For page containing |object| mark region covering |address| | 192 // For page containing |object| mark region covering |address| |
| 239 // dirty. |object| is the object being stored into, |value| is the | 193 // dirty. |object| is the object being stored into, |value| is the |
| 240 // object being stored. The address and value registers are clobbered by the | 194 // object being stored. The address and value registers are clobbered by the |
| 241 // operation. RecordWrite filters out smis so it does not update the | 195 // operation. RecordWrite filters out smis so it does not update the |
| 242 // write barrier if the value is a smi. | 196 // write barrier if the value is a smi. |
| 243 void RecordWrite( | 197 void RecordWrite( |
| 244 Register object, | 198 Register object, Register address, Register value, SaveFPRegsMode save_fp, |
| 245 Register address, | |
| 246 Register value, | |
| 247 SaveFPRegsMode save_fp, | |
| 248 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, | 199 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, |
| 249 SmiCheck smi_check = INLINE_SMI_CHECK, | 200 SmiCheck smi_check = INLINE_SMI_CHECK, |
| 250 PointersToHereCheck pointers_to_here_check_for_value = | 201 PointersToHereCheck pointers_to_here_check_for_value = |
| 251 kPointersToHereMaybeInteresting); | 202 kPointersToHereMaybeInteresting); |
| 252 | 203 |
| 253 // For page containing |object| mark the region covering the object's map | 204 // For page containing |object| mark the region covering the object's map |
| 254 // dirty. |object| is the object being stored into, |map| is the Map object | 205 // dirty. |object| is the object being stored into, |map| is the Map object |
| 255 // that was stored. | 206 // that was stored. |
| 256 void RecordWriteForMap( | 207 void RecordWriteForMap(Register object, Handle<Map> map, Register scratch1, |
| 257 Register object, | 208 Register scratch2, SaveFPRegsMode save_fp); |
| 258 Handle<Map> map, | |
| 259 Register scratch1, | |
| 260 Register scratch2, | |
| 261 SaveFPRegsMode save_fp); | |
| 262 | 209 |
| 263 // --------------------------------------------------------------------------- | 210 // --------------------------------------------------------------------------- |
| 264 // Debugger Support | 211 // Debugger Support |
| 265 | 212 |
| 266 void DebugBreak(); | 213 void DebugBreak(); |
| 267 | 214 |
| 268 // Generates function and stub prologue code. | 215 // Generates function and stub prologue code. |
| 269 void StubPrologue(); | 216 void StubPrologue(); |
| 270 void Prologue(bool code_pre_aging); | 217 void Prologue(bool code_pre_aging); |
| 271 | 218 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 289 // Find the function context up the context chain. | 236 // Find the function context up the context chain. |
| 290 void LoadContext(Register dst, int context_chain_length); | 237 void LoadContext(Register dst, int context_chain_length); |
| 291 | 238 |
| 292 // Load the global proxy from the current context. | 239 // Load the global proxy from the current context. |
| 293 void LoadGlobalProxy(Register dst); | 240 void LoadGlobalProxy(Register dst); |
| 294 | 241 |
| 295 // Conditionally load the cached Array transitioned map of type | 242 // Conditionally load the cached Array transitioned map of type |
| 296 // transitioned_kind from the native context if the map in register | 243 // transitioned_kind from the native context if the map in register |
| 297 // map_in_out is the cached Array map in the native context of | 244 // map_in_out is the cached Array map in the native context of |
| 298 // expected_kind. | 245 // expected_kind. |
| 299 void LoadTransitionedArrayMapConditional( | 246 void LoadTransitionedArrayMapConditional(ElementsKind expected_kind, |
| 300 ElementsKind expected_kind, | 247 ElementsKind transitioned_kind, |
| 301 ElementsKind transitioned_kind, | 248 Register map_in_out, |
| 302 Register map_in_out, | 249 Register scratch, |
| 303 Register scratch, | 250 Label* no_map_match); |
| 304 Label* no_map_match); | |
| 305 | 251 |
| 306 // Load the global function with the given index. | 252 // Load the global function with the given index. |
| 307 void LoadGlobalFunction(int index, Register function); | 253 void LoadGlobalFunction(int index, Register function); |
| 308 | 254 |
| 309 // Load the initial map from the global function. The registers | 255 // Load the initial map from the global function. The registers |
| 310 // function and map can be the same. | 256 // function and map can be the same. |
| 311 void LoadGlobalFunctionInitialMap(Register function, Register map); | 257 void LoadGlobalFunctionInitialMap(Register function, Register map); |
| 312 | 258 |
| 313 // Push and pop the registers that can hold pointers. | 259 // Push and pop the registers that can hold pointers. |
| 314 void PushSafepointRegisters() { pushad(); } | 260 void PushSafepointRegisters() { pushad(); } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 void GetWeakValue(Register value, Handle<WeakCell> cell); | 293 void GetWeakValue(Register value, Handle<WeakCell> cell); |
| 348 | 294 |
| 349 // Load the value of the weak cell in the value register. Branch to the given | 295 // Load the value of the weak cell in the value register. Branch to the given |
| 350 // miss label if the weak cell was cleared. | 296 // miss label if the weak cell was cleared. |
| 351 void LoadWeakValue(Register value, Handle<WeakCell> cell, Label* miss); | 297 void LoadWeakValue(Register value, Handle<WeakCell> cell, Label* miss); |
| 352 | 298 |
| 353 // --------------------------------------------------------------------------- | 299 // --------------------------------------------------------------------------- |
| 354 // JavaScript invokes | 300 // JavaScript invokes |
| 355 | 301 |
| 356 // Invoke the JavaScript function code by either calling or jumping. | 302 // Invoke the JavaScript function code by either calling or jumping. |
| 357 void InvokeCode(Register code, | |
| 358 const ParameterCount& expected, | |
| 359 const ParameterCount& actual, | |
| 360 InvokeFlag flag, | |
| 361 const CallWrapper& call_wrapper) { | |
| 362 InvokeCode(Operand(code), no_reg, expected, actual, flag, call_wrapper); | |
| 363 } | |
| 364 | 303 |
| 365 void InvokeCode(const Operand& code, | 304 void InvokeFunctionCode(Register function, Register new_target, |
| 366 Register new_target, | 305 const ParameterCount& expected, |
| 367 const ParameterCount& expected, | 306 const ParameterCount& actual, InvokeFlag flag, |
| 368 const ParameterCount& actual, | 307 const CallWrapper& call_wrapper); |
| 369 InvokeFlag flag, | |
| 370 const CallWrapper& call_wrapper); | |
| 371 | 308 |
| 372 // Invoke the JavaScript function in the given register. Changes the | 309 // Invoke the JavaScript function in the given register. Changes the |
| 373 // current context to the context in the function before invoking. | 310 // current context to the context in the function before invoking. |
| 374 void InvokeFunction(Register function, | 311 void InvokeFunction(Register function, Register new_target, |
| 375 Register new_target, | 312 const ParameterCount& actual, InvokeFlag flag, |
| 376 const ParameterCount& actual, | |
| 377 InvokeFlag flag, | |
| 378 const CallWrapper& call_wrapper); | 313 const CallWrapper& call_wrapper); |
| 379 | 314 |
| 380 void InvokeFunction(Register function, | 315 void InvokeFunction(Register function, const ParameterCount& expected, |
| 381 const ParameterCount& expected, | 316 const ParameterCount& actual, InvokeFlag flag, |
| 382 const ParameterCount& actual, | |
| 383 InvokeFlag flag, | |
| 384 const CallWrapper& call_wrapper); | 317 const CallWrapper& call_wrapper); |
| 385 | 318 |
| 386 void InvokeFunction(Handle<JSFunction> function, | 319 void InvokeFunction(Handle<JSFunction> function, |
| 387 const ParameterCount& expected, | 320 const ParameterCount& expected, |
| 388 const ParameterCount& actual, | 321 const ParameterCount& actual, InvokeFlag flag, |
| 389 InvokeFlag flag, | |
| 390 const CallWrapper& call_wrapper); | 322 const CallWrapper& call_wrapper); |
| 391 | 323 |
| 392 // Invoke specified builtin JavaScript function. | 324 // Invoke specified builtin JavaScript function. |
| 393 void InvokeBuiltin(int native_context_index, InvokeFlag flag, | 325 void InvokeBuiltin(int native_context_index, InvokeFlag flag, |
| 394 const CallWrapper& call_wrapper = NullCallWrapper()); | 326 const CallWrapper& call_wrapper = NullCallWrapper()); |
| 395 | 327 |
| 396 // Store the function for the given builtin in the target register. | 328 // Store the function for the given builtin in the target register. |
| 397 void GetBuiltinFunction(Register target, int native_context_index); | 329 void GetBuiltinFunction(Register target, int native_context_index); |
| 398 | 330 |
| 399 // Store the code object for the given builtin in the target register. | |
| 400 void GetBuiltinEntry(Register target, int native_context_index); | |
| 401 | |
| 402 // Expression support | 331 // Expression support |
| 403 // cvtsi2sd instruction only writes to the low 64-bit of dst register, which | 332 // cvtsi2sd instruction only writes to the low 64-bit of dst register, which |
| 404 // hinders register renaming and makes dependence chains longer. So we use | 333 // hinders register renaming and makes dependence chains longer. So we use |
| 405 // xorps to clear the dst register before cvtsi2sd to solve this issue. | 334 // xorps to clear the dst register before cvtsi2sd to solve this issue. |
| 406 void Cvtsi2sd(XMMRegister dst, Register src) { Cvtsi2sd(dst, Operand(src)); } | 335 void Cvtsi2sd(XMMRegister dst, Register src) { Cvtsi2sd(dst, Operand(src)); } |
| 407 void Cvtsi2sd(XMMRegister dst, const Operand& src); | 336 void Cvtsi2sd(XMMRegister dst, const Operand& src); |
| 408 | 337 |
| 409 // Support for constant splitting. | 338 // Support for constant splitting. |
| 410 bool IsUnsafeImmediate(const Immediate& x); | 339 bool IsUnsafeImmediate(const Immediate& x); |
| 411 void SafeMove(Register dst, const Immediate& x); | 340 void SafeMove(Register dst, const Immediate& x); |
| 412 void SafePush(const Immediate& x); | 341 void SafePush(const Immediate& x); |
| 413 | 342 |
| 414 // Compare object type for heap object. | 343 // Compare object type for heap object. |
| 415 // Incoming register is heap_object and outgoing register is map. | 344 // Incoming register is heap_object and outgoing register is map. |
| 416 void CmpObjectType(Register heap_object, InstanceType type, Register map); | 345 void CmpObjectType(Register heap_object, InstanceType type, Register map); |
| 417 | 346 |
| 418 // Compare instance type for map. | 347 // Compare instance type for map. |
| 419 void CmpInstanceType(Register map, InstanceType type); | 348 void CmpInstanceType(Register map, InstanceType type); |
| 420 | 349 |
| 421 // Check if a map for a JSObject indicates that the object has fast elements. | 350 // Check if a map for a JSObject indicates that the object has fast elements. |
| 422 // Jump to the specified label if it does not. | 351 // Jump to the specified label if it does not. |
| 423 void CheckFastElements(Register map, | 352 void CheckFastElements(Register map, Label* fail, |
| 424 Label* fail, | |
| 425 Label::Distance distance = Label::kFar); | 353 Label::Distance distance = Label::kFar); |
| 426 | 354 |
| 427 // Check if a map for a JSObject indicates that the object can have both smi | 355 // Check if a map for a JSObject indicates that the object can have both smi |
| 428 // and HeapObject elements. Jump to the specified label if it does not. | 356 // and HeapObject elements. Jump to the specified label if it does not. |
| 429 void CheckFastObjectElements(Register map, | 357 void CheckFastObjectElements(Register map, Label* fail, |
| 430 Label* fail, | |
| 431 Label::Distance distance = Label::kFar); | 358 Label::Distance distance = Label::kFar); |
| 432 | 359 |
| 433 // Check if a map for a JSObject indicates that the object has fast smi only | 360 // Check if a map for a JSObject indicates that the object has fast smi only |
| 434 // elements. Jump to the specified label if it does not. | 361 // elements. Jump to the specified label if it does not. |
| 435 void CheckFastSmiElements(Register map, | 362 void CheckFastSmiElements(Register map, Label* fail, |
| 436 Label* fail, | |
| 437 Label::Distance distance = Label::kFar); | 363 Label::Distance distance = Label::kFar); |
| 438 | 364 |
| 439 // Check to see if maybe_number can be stored as a double in | 365 // Check to see if maybe_number can be stored as a double in |
| 440 // FastDoubleElements. If it can, store it at the index specified by key in | 366 // FastDoubleElements. If it can, store it at the index specified by key in |
| 441 // the FastDoubleElements array elements, otherwise jump to fail. | 367 // the FastDoubleElements array elements, otherwise jump to fail. |
| 442 void StoreNumberToDoubleElements(Register maybe_number, | 368 void StoreNumberToDoubleElements(Register maybe_number, Register elements, |
| 443 Register elements, | 369 Register key, Register scratch1, |
| 444 Register key, | 370 XMMRegister scratch2, Label* fail, |
| 445 Register scratch1, | |
| 446 XMMRegister scratch2, | |
| 447 Label* fail, | |
| 448 int offset = 0); | 371 int offset = 0); |
| 449 | 372 |
| 450 // Compare an object's map with the specified map. | 373 // Compare an object's map with the specified map. |
| 451 void CompareMap(Register obj, Handle<Map> map); | 374 void CompareMap(Register obj, Handle<Map> map); |
| 452 | 375 |
| 453 // Check if the map of an object is equal to a specified map and branch to | 376 // Check if the map of an object is equal to a specified map and branch to |
| 454 // label if not. Skip the smi check if not required (object is known to be a | 377 // label if not. Skip the smi check if not required (object is known to be a |
| 455 // heap object). If mode is ALLOW_ELEMENT_TRANSITION_MAPS, then also match | 378 // heap object). If mode is ALLOW_ELEMENT_TRANSITION_MAPS, then also match |
| 456 // against maps that are ElementsKind transition maps of the specified map. | 379 // against maps that are ElementsKind transition maps of the specified map. |
| 457 void CheckMap(Register obj, | 380 void CheckMap(Register obj, Handle<Map> map, Label* fail, |
| 458 Handle<Map> map, | |
| 459 Label* fail, | |
| 460 SmiCheckType smi_check_type); | 381 SmiCheckType smi_check_type); |
| 461 | 382 |
| 462 // Check if the map of an object is equal to a specified weak map and branch | 383 // Check if the map of an object is equal to a specified weak map and branch |
| 463 // to a specified target if equal. Skip the smi check if not required | 384 // to a specified target if equal. Skip the smi check if not required |
| 464 // (object is known to be a heap object) | 385 // (object is known to be a heap object) |
| 465 void DispatchWeakMap(Register obj, Register scratch1, Register scratch2, | 386 void DispatchWeakMap(Register obj, Register scratch1, Register scratch2, |
| 466 Handle<WeakCell> cell, Handle<Code> success, | 387 Handle<WeakCell> cell, Handle<Code> success, |
| 467 SmiCheckType smi_check_type); | 388 SmiCheckType smi_check_type); |
| 468 | 389 |
| 469 // Check if the object in register heap_object is a string. Afterwards the | 390 // Check if the object in register heap_object is a string. Afterwards the |
| 470 // register map contains the object map and the register instance_type | 391 // register map contains the object map and the register instance_type |
| 471 // contains the instance_type. The registers map and instance_type can be the | 392 // contains the instance_type. The registers map and instance_type can be the |
| 472 // same in which case it contains the instance type afterwards. Either of the | 393 // same in which case it contains the instance type afterwards. Either of the |
| 473 // registers map and instance_type can be the same as heap_object. | 394 // registers map and instance_type can be the same as heap_object. |
| 474 Condition IsObjectStringType(Register heap_object, | 395 Condition IsObjectStringType(Register heap_object, Register map, |
| 475 Register map, | |
| 476 Register instance_type); | 396 Register instance_type); |
| 477 | 397 |
| 478 // Check if the object in register heap_object is a name. Afterwards the | 398 // Check if the object in register heap_object is a name. Afterwards the |
| 479 // register map contains the object map and the register instance_type | 399 // register map contains the object map and the register instance_type |
| 480 // contains the instance_type. The registers map and instance_type can be the | 400 // contains the instance_type. The registers map and instance_type can be the |
| 481 // same in which case it contains the instance type afterwards. Either of the | 401 // same in which case it contains the instance type afterwards. Either of the |
| 482 // registers map and instance_type can be the same as heap_object. | 402 // registers map and instance_type can be the same as heap_object. |
| 483 Condition IsObjectNameType(Register heap_object, | 403 Condition IsObjectNameType(Register heap_object, Register map, |
| 484 Register map, | |
| 485 Register instance_type); | 404 Register instance_type); |
| 486 | 405 |
| 487 // FCmp is similar to integer cmp, but requires unsigned | 406 // FCmp is similar to integer cmp, but requires unsigned |
| 488 // jcc instructions (je, ja, jae, jb, jbe, je, and jz). | 407 // jcc instructions (je, ja, jae, jb, jbe, je, and jz). |
| 489 void FCmp(); | 408 void FCmp(); |
| 490 | 409 |
| 491 void ClampUint8(Register reg); | 410 void ClampUint8(Register reg); |
| 492 | 411 |
| 493 void ClampDoubleToUint8(XMMRegister input_reg, | 412 void ClampDoubleToUint8(XMMRegister input_reg, XMMRegister scratch_reg, |
| 494 XMMRegister scratch_reg, | |
| 495 Register result_reg); | 413 Register result_reg); |
| 496 | 414 |
| 497 void SlowTruncateToI(Register result_reg, Register input_reg, | 415 void SlowTruncateToI(Register result_reg, Register input_reg, |
| 498 int offset = HeapNumber::kValueOffset - kHeapObjectTag); | 416 int offset = HeapNumber::kValueOffset - kHeapObjectTag); |
| 499 | 417 |
| 500 void TruncateHeapNumberToI(Register result_reg, Register input_reg); | 418 void TruncateHeapNumberToI(Register result_reg, Register input_reg); |
| 501 void TruncateDoubleToI(Register result_reg, XMMRegister input_reg); | 419 void TruncateDoubleToI(Register result_reg, XMMRegister input_reg); |
| 502 | 420 |
| 503 void DoubleToI(Register result_reg, XMMRegister input_reg, | 421 void DoubleToI(Register result_reg, XMMRegister input_reg, |
| 504 XMMRegister scratch, MinusZeroMode minus_zero_mode, | 422 XMMRegister scratch, MinusZeroMode minus_zero_mode, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 522 STATIC_ASSERT(kSmiTag == 0); | 440 STATIC_ASSERT(kSmiTag == 0); |
| 523 j(not_carry, is_smi); | 441 j(not_carry, is_smi); |
| 524 } | 442 } |
| 525 | 443 |
| 526 void LoadUint32(XMMRegister dst, Register src) { | 444 void LoadUint32(XMMRegister dst, Register src) { |
| 527 LoadUint32(dst, Operand(src)); | 445 LoadUint32(dst, Operand(src)); |
| 528 } | 446 } |
| 529 void LoadUint32(XMMRegister dst, const Operand& src); | 447 void LoadUint32(XMMRegister dst, const Operand& src); |
| 530 | 448 |
| 531 // Jump the register contains a smi. | 449 // Jump the register contains a smi. |
| 532 inline void JumpIfSmi(Register value, | 450 inline void JumpIfSmi(Register value, Label* smi_label, |
| 533 Label* smi_label, | |
| 534 Label::Distance distance = Label::kFar) { | 451 Label::Distance distance = Label::kFar) { |
| 535 test(value, Immediate(kSmiTagMask)); | 452 test(value, Immediate(kSmiTagMask)); |
| 536 j(zero, smi_label, distance); | 453 j(zero, smi_label, distance); |
| 537 } | 454 } |
| 538 // Jump if the operand is a smi. | 455 // Jump if the operand is a smi. |
| 539 inline void JumpIfSmi(Operand value, | 456 inline void JumpIfSmi(Operand value, Label* smi_label, |
| 540 Label* smi_label, | |
| 541 Label::Distance distance = Label::kFar) { | 457 Label::Distance distance = Label::kFar) { |
| 542 test(value, Immediate(kSmiTagMask)); | 458 test(value, Immediate(kSmiTagMask)); |
| 543 j(zero, smi_label, distance); | 459 j(zero, smi_label, distance); |
| 544 } | 460 } |
| 545 // Jump if register contain a non-smi. | 461 // Jump if register contain a non-smi. |
| 546 inline void JumpIfNotSmi(Register value, | 462 inline void JumpIfNotSmi(Register value, Label* not_smi_label, |
| 547 Label* not_smi_label, | |
| 548 Label::Distance distance = Label::kFar) { | 463 Label::Distance distance = Label::kFar) { |
| 549 test(value, Immediate(kSmiTagMask)); | 464 test(value, Immediate(kSmiTagMask)); |
| 550 j(not_zero, not_smi_label, distance); | 465 j(not_zero, not_smi_label, distance); |
| 551 } | 466 } |
| 552 | 467 |
| 553 void LoadInstanceDescriptors(Register map, Register descriptors); | 468 void LoadInstanceDescriptors(Register map, Register descriptors); |
| 554 void EnumLength(Register dst, Register map); | 469 void EnumLength(Register dst, Register map); |
| 555 void NumberOfOwnDescriptors(Register dst, Register map); | 470 void NumberOfOwnDescriptors(Register dst, Register map); |
| 556 void LoadAccessor(Register dst, Register holder, int accessor_index, | 471 void LoadAccessor(Register dst, Register holder, int accessor_index, |
| 557 AccessorComponent accessor); | 472 AccessorComponent accessor); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 527 |
| 613 // Unlink the stack handler on top of the stack from the stack handler chain. | 528 // Unlink the stack handler on top of the stack from the stack handler chain. |
| 614 void PopStackHandler(); | 529 void PopStackHandler(); |
| 615 | 530 |
| 616 // --------------------------------------------------------------------------- | 531 // --------------------------------------------------------------------------- |
| 617 // Inline caching support | 532 // Inline caching support |
| 618 | 533 |
| 619 // Generate code for checking access rights - used for security checks | 534 // Generate code for checking access rights - used for security checks |
| 620 // on access to global objects across environments. The holder register | 535 // on access to global objects across environments. The holder register |
| 621 // is left untouched, but the scratch register is clobbered. | 536 // is left untouched, but the scratch register is clobbered. |
| 622 void CheckAccessGlobalProxy(Register holder_reg, | 537 void CheckAccessGlobalProxy(Register holder_reg, Register scratch1, |
| 623 Register scratch1, | 538 Register scratch2, Label* miss); |
| 624 Register scratch2, | |
| 625 Label* miss); | |
| 626 | 539 |
| 627 void GetNumberHash(Register r0, Register scratch); | 540 void GetNumberHash(Register r0, Register scratch); |
| 628 | 541 |
| 629 void LoadFromNumberDictionary(Label* miss, | 542 void LoadFromNumberDictionary(Label* miss, Register elements, Register key, |
| 630 Register elements, | 543 Register r0, Register r1, Register r2, |
| 631 Register key, | |
| 632 Register r0, | |
| 633 Register r1, | |
| 634 Register r2, | |
| 635 Register result); | 544 Register result); |
| 636 | 545 |
| 637 | |
| 638 // --------------------------------------------------------------------------- | 546 // --------------------------------------------------------------------------- |
| 639 // Allocation support | 547 // Allocation support |
| 640 | 548 |
| 641 // Allocate an object in new space or old space. If the given space | 549 // Allocate an object in new space or old space. If the given space |
| 642 // is exhausted control continues at the gc_required label. The allocated | 550 // is exhausted control continues at the gc_required label. The allocated |
| 643 // object is returned in result and end of the new object is returned in | 551 // object is returned in result and end of the new object is returned in |
| 644 // result_end. The register scratch can be passed as no_reg in which case | 552 // result_end. The register scratch can be passed as no_reg in which case |
| 645 // an additional object reference will be added to the reloc info. The | 553 // an additional object reference will be added to the reloc info. The |
| 646 // returned pointers in result and result_end have not yet been tagged as | 554 // returned pointers in result and result_end have not yet been tagged as |
| 647 // heap objects. If result_contains_top_on_entry is true the content of | 555 // heap objects. If result_contains_top_on_entry is true the content of |
| 648 // result is known to be the allocation top on entry (could be result_end | 556 // result is known to be the allocation top on entry (could be result_end |
| 649 // from a previous call). If result_contains_top_on_entry is true scratch | 557 // from a previous call). If result_contains_top_on_entry is true scratch |
| 650 // should be no_reg as it is never used. | 558 // should be no_reg as it is never used. |
| 651 void Allocate(int object_size, | 559 void Allocate(int object_size, Register result, Register result_end, |
| 652 Register result, | 560 Register scratch, Label* gc_required, AllocationFlags flags); |
| 653 Register result_end, | |
| 654 Register scratch, | |
| 655 Label* gc_required, | |
| 656 AllocationFlags flags); | |
| 657 | 561 |
| 658 void Allocate(int header_size, | 562 void Allocate(int header_size, ScaleFactor element_size, |
| 659 ScaleFactor element_size, | 563 Register element_count, RegisterValueType element_count_type, |
| 660 Register element_count, | 564 Register result, Register result_end, Register scratch, |
| 661 RegisterValueType element_count_type, | 565 Label* gc_required, AllocationFlags flags); |
| 662 Register result, | |
| 663 Register result_end, | |
| 664 Register scratch, | |
| 665 Label* gc_required, | |
| 666 AllocationFlags flags); | |
| 667 | 566 |
| 668 void Allocate(Register object_size, | 567 void Allocate(Register object_size, Register result, Register result_end, |
| 669 Register result, | 568 Register scratch, Label* gc_required, AllocationFlags flags); |
| 670 Register result_end, | |
| 671 Register scratch, | |
| 672 Label* gc_required, | |
| 673 AllocationFlags flags); | |
| 674 | 569 |
| 675 // Allocate a heap number in new space with undefined value. The | 570 // Allocate a heap number in new space with undefined value. The |
| 676 // register scratch2 can be passed as no_reg; the others must be | 571 // register scratch2 can be passed as no_reg; the others must be |
| 677 // valid registers. Returns tagged pointer in result register, or | 572 // valid registers. Returns tagged pointer in result register, or |
| 678 // jumps to gc_required if new space is full. | 573 // jumps to gc_required if new space is full. |
| 679 void AllocateHeapNumber(Register result, | 574 void AllocateHeapNumber(Register result, Register scratch1, Register scratch2, |
| 680 Register scratch1, | 575 Label* gc_required, MutableMode mode = IMMUTABLE); |
| 681 Register scratch2, | |
| 682 Label* gc_required, | |
| 683 MutableMode mode = IMMUTABLE); | |
| 684 | 576 |
| 685 // Allocate a sequential string. All the header fields of the string object | 577 // Allocate a sequential string. All the header fields of the string object |
| 686 // are initialized. | 578 // are initialized. |
| 687 void AllocateTwoByteString(Register result, | 579 void AllocateTwoByteString(Register result, Register length, |
| 688 Register length, | 580 Register scratch1, Register scratch2, |
| 689 Register scratch1, | 581 Register scratch3, Label* gc_required); |
| 690 Register scratch2, | |
| 691 Register scratch3, | |
| 692 Label* gc_required); | |
| 693 void AllocateOneByteString(Register result, Register length, | 582 void AllocateOneByteString(Register result, Register length, |
| 694 Register scratch1, Register scratch2, | 583 Register scratch1, Register scratch2, |
| 695 Register scratch3, Label* gc_required); | 584 Register scratch3, Label* gc_required); |
| 696 void AllocateOneByteString(Register result, int length, Register scratch1, | 585 void AllocateOneByteString(Register result, int length, Register scratch1, |
| 697 Register scratch2, Label* gc_required); | 586 Register scratch2, Label* gc_required); |
| 698 | 587 |
| 699 // Allocate a raw cons string object. Only the map field of the result is | 588 // Allocate a raw cons string object. Only the map field of the result is |
| 700 // initialized. | 589 // initialized. |
| 701 void AllocateTwoByteConsString(Register result, | 590 void AllocateTwoByteConsString(Register result, Register scratch1, |
| 702 Register scratch1, | 591 Register scratch2, Label* gc_required); |
| 703 Register scratch2, | |
| 704 Label* gc_required); | |
| 705 void AllocateOneByteConsString(Register result, Register scratch1, | 592 void AllocateOneByteConsString(Register result, Register scratch1, |
| 706 Register scratch2, Label* gc_required); | 593 Register scratch2, Label* gc_required); |
| 707 | 594 |
| 708 // Allocate a raw sliced string object. Only the map field of the result is | 595 // Allocate a raw sliced string object. Only the map field of the result is |
| 709 // initialized. | 596 // initialized. |
| 710 void AllocateTwoByteSlicedString(Register result, | 597 void AllocateTwoByteSlicedString(Register result, Register scratch1, |
| 711 Register scratch1, | 598 Register scratch2, Label* gc_required); |
| 712 Register scratch2, | |
| 713 Label* gc_required); | |
| 714 void AllocateOneByteSlicedString(Register result, Register scratch1, | 599 void AllocateOneByteSlicedString(Register result, Register scratch1, |
| 715 Register scratch2, Label* gc_required); | 600 Register scratch2, Label* gc_required); |
| 716 | 601 |
| 717 // Copy memory, byte-by-byte, from source to destination. Not optimized for | 602 // Copy memory, byte-by-byte, from source to destination. Not optimized for |
| 718 // long or aligned copies. | 603 // long or aligned copies. |
| 719 // The contents of index and scratch are destroyed. | 604 // The contents of index and scratch are destroyed. |
| 720 void CopyBytes(Register source, | 605 void CopyBytes(Register source, Register destination, Register length, |
| 721 Register destination, | |
| 722 Register length, | |
| 723 Register scratch); | 606 Register scratch); |
| 724 | 607 |
| 725 // Initialize fields with filler values. Fields starting at |current_address| | 608 // Initialize fields with filler values. Fields starting at |current_address| |
| 726 // not including |end_address| are overwritten with the value in |filler|. At | 609 // not including |end_address| are overwritten with the value in |filler|. At |
| 727 // the end the loop, |current_address| takes the value of |end_address|. | 610 // the end the loop, |current_address| takes the value of |end_address|. |
| 728 void InitializeFieldsWithFiller(Register current_address, | 611 void InitializeFieldsWithFiller(Register current_address, |
| 729 Register end_address, Register filler); | 612 Register end_address, Register filler); |
| 730 | 613 |
| 731 // --------------------------------------------------------------------------- | 614 // --------------------------------------------------------------------------- |
| 732 // Support functions. | 615 // Support functions. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 // Call a code stub. Generate the code if necessary. | 649 // Call a code stub. Generate the code if necessary. |
| 767 void CallStub(CodeStub* stub, TypeFeedbackId ast_id = TypeFeedbackId::None()); | 650 void CallStub(CodeStub* stub, TypeFeedbackId ast_id = TypeFeedbackId::None()); |
| 768 | 651 |
| 769 // Tail call a code stub (jump). Generate the code if necessary. | 652 // Tail call a code stub (jump). Generate the code if necessary. |
| 770 void TailCallStub(CodeStub* stub); | 653 void TailCallStub(CodeStub* stub); |
| 771 | 654 |
| 772 // Return from a code stub after popping its arguments. | 655 // Return from a code stub after popping its arguments. |
| 773 void StubReturn(int argc); | 656 void StubReturn(int argc); |
| 774 | 657 |
| 775 // Call a runtime routine. | 658 // Call a runtime routine. |
| 776 void CallRuntime(const Runtime::Function* f, | 659 void CallRuntime(const Runtime::Function* f, int num_arguments, |
| 777 int num_arguments, | |
| 778 SaveFPRegsMode save_doubles = kDontSaveFPRegs); | 660 SaveFPRegsMode save_doubles = kDontSaveFPRegs); |
| 779 void CallRuntimeSaveDoubles(Runtime::FunctionId id) { | 661 void CallRuntimeSaveDoubles(Runtime::FunctionId id) { |
| 780 const Runtime::Function* function = Runtime::FunctionForId(id); | 662 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 781 CallRuntime(function, function->nargs, kSaveFPRegs); | 663 CallRuntime(function, function->nargs, kSaveFPRegs); |
| 782 } | 664 } |
| 783 | 665 |
| 784 // Convenience function: Same as above, but takes the fid instead. | 666 // Convenience function: Same as above, but takes the fid instead. |
| 785 void CallRuntime(Runtime::FunctionId id, | 667 void CallRuntime(Runtime::FunctionId id, int num_arguments, |
| 786 int num_arguments, | |
| 787 SaveFPRegsMode save_doubles = kDontSaveFPRegs) { | 668 SaveFPRegsMode save_doubles = kDontSaveFPRegs) { |
| 788 CallRuntime(Runtime::FunctionForId(id), num_arguments, save_doubles); | 669 CallRuntime(Runtime::FunctionForId(id), num_arguments, save_doubles); |
| 789 } | 670 } |
| 790 | 671 |
| 791 // Convenience function: call an external reference. | 672 // Convenience function: call an external reference. |
| 792 void CallExternalReference(ExternalReference ref, int num_arguments); | 673 void CallExternalReference(ExternalReference ref, int num_arguments); |
| 793 | 674 |
| 794 // Tail call of a runtime routine (jump). | 675 // Tail call of a runtime routine (jump). |
| 795 // Like JumpToExternalReference, but also takes care of passing the number | 676 // Like JumpToExternalReference, but also takes care of passing the number |
| 796 // of parameters. | 677 // of parameters. |
| 797 void TailCallExternalReference(const ExternalReference& ext, | 678 void TailCallExternalReference(const ExternalReference& ext, |
| 798 int num_arguments, | 679 int num_arguments, int result_size); |
| 799 int result_size); | |
| 800 | 680 |
| 801 // Convenience function: tail call a runtime routine (jump). | 681 // Convenience function: tail call a runtime routine (jump). |
| 802 void TailCallRuntime(Runtime::FunctionId fid, | 682 void TailCallRuntime(Runtime::FunctionId fid, int num_arguments, |
| 803 int num_arguments, | |
| 804 int result_size); | 683 int result_size); |
| 805 | 684 |
| 806 // Before calling a C-function from generated code, align arguments on stack. | 685 // Before calling a C-function from generated code, align arguments on stack. |
| 807 // After aligning the frame, arguments must be stored in esp[0], esp[4], | 686 // After aligning the frame, arguments must be stored in esp[0], esp[4], |
| 808 // etc., not pushed. The argument count assumes all arguments are word sized. | 687 // etc., not pushed. The argument count assumes all arguments are word sized. |
| 809 // Some compilers/platforms require the stack to be aligned when calling | 688 // Some compilers/platforms require the stack to be aligned when calling |
| 810 // C++ code. | 689 // C++ code. |
| 811 // Needs a scratch register to do some arithmetic. This register will be | 690 // Needs a scratch register to do some arithmetic. This register will be |
| 812 // trashed. | 691 // trashed. |
| 813 void PrepareCallCFunction(int num_arguments, Register scratch); | 692 void PrepareCallCFunction(int num_arguments, Register scratch); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 775 |
| 897 // --------------------------------------------------------------------------- | 776 // --------------------------------------------------------------------------- |
| 898 // StatsCounter support | 777 // StatsCounter support |
| 899 | 778 |
| 900 void SetCounter(StatsCounter* counter, int value); | 779 void SetCounter(StatsCounter* counter, int value); |
| 901 void IncrementCounter(StatsCounter* counter, int value); | 780 void IncrementCounter(StatsCounter* counter, int value); |
| 902 void DecrementCounter(StatsCounter* counter, int value); | 781 void DecrementCounter(StatsCounter* counter, int value); |
| 903 void IncrementCounter(Condition cc, StatsCounter* counter, int value); | 782 void IncrementCounter(Condition cc, StatsCounter* counter, int value); |
| 904 void DecrementCounter(Condition cc, StatsCounter* counter, int value); | 783 void DecrementCounter(Condition cc, StatsCounter* counter, int value); |
| 905 | 784 |
| 906 | |
| 907 // --------------------------------------------------------------------------- | 785 // --------------------------------------------------------------------------- |
| 908 // Debugging | 786 // Debugging |
| 909 | 787 |
| 910 // Calls Abort(msg) if the condition cc is not satisfied. | 788 // Calls Abort(msg) if the condition cc is not satisfied. |
| 911 // Use --debug_code to enable. | 789 // Use --debug_code to enable. |
| 912 void Assert(Condition cc, BailoutReason reason); | 790 void Assert(Condition cc, BailoutReason reason); |
| 913 | 791 |
| 914 void AssertFastElements(Register elements); | 792 void AssertFastElements(Register elements); |
| 915 | 793 |
| 916 // Like Assert(), but always enabled. | 794 // Like Assert(), but always enabled. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 947 | 825 |
| 948 // Checks if the given register or operand is a unique name | 826 // Checks if the given register or operand is a unique name |
| 949 void JumpIfNotUniqueNameInstanceType(Register reg, Label* not_unique_name, | 827 void JumpIfNotUniqueNameInstanceType(Register reg, Label* not_unique_name, |
| 950 Label::Distance distance = Label::kFar) { | 828 Label::Distance distance = Label::kFar) { |
| 951 JumpIfNotUniqueNameInstanceType(Operand(reg), not_unique_name, distance); | 829 JumpIfNotUniqueNameInstanceType(Operand(reg), not_unique_name, distance); |
| 952 } | 830 } |
| 953 | 831 |
| 954 void JumpIfNotUniqueNameInstanceType(Operand operand, Label* not_unique_name, | 832 void JumpIfNotUniqueNameInstanceType(Operand operand, Label* not_unique_name, |
| 955 Label::Distance distance = Label::kFar); | 833 Label::Distance distance = Label::kFar); |
| 956 | 834 |
| 957 void EmitSeqStringSetCharCheck(Register string, | 835 void EmitSeqStringSetCharCheck(Register string, Register index, |
| 958 Register index, | 836 Register value, uint32_t encoding_mask); |
| 959 Register value, | |
| 960 uint32_t encoding_mask); | |
| 961 | 837 |
| 962 static int SafepointRegisterStackIndex(Register reg) { | 838 static int SafepointRegisterStackIndex(Register reg) { |
| 963 return SafepointRegisterStackIndex(reg.code()); | 839 return SafepointRegisterStackIndex(reg.code()); |
| 964 } | 840 } |
| 965 | 841 |
| 966 // Load the type feedback vector from a JavaScript frame. | 842 // Load the type feedback vector from a JavaScript frame. |
| 967 void EmitLoadTypeFeedbackVector(Register vector); | 843 void EmitLoadTypeFeedbackVector(Register vector); |
| 968 | 844 |
| 969 // Activation support. | 845 // Activation support. |
| 970 void EnterFrame(StackFrame::Type type); | 846 void EnterFrame(StackFrame::Type type); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1000 Register scratch1, Label* found); | 876 Register scratch1, Label* found); |
| 1001 | 877 |
| 1002 private: | 878 private: |
| 1003 bool generating_stub_; | 879 bool generating_stub_; |
| 1004 bool has_frame_; | 880 bool has_frame_; |
| 1005 // This handle will be patched with the code object on installation. | 881 // This handle will be patched with the code object on installation. |
| 1006 Handle<Object> code_object_; | 882 Handle<Object> code_object_; |
| 1007 | 883 |
| 1008 // Helper functions for generating invokes. | 884 // Helper functions for generating invokes. |
| 1009 void InvokePrologue(const ParameterCount& expected, | 885 void InvokePrologue(const ParameterCount& expected, |
| 1010 const ParameterCount& actual, | 886 const ParameterCount& actual, Label* done, |
| 1011 Label* done, | 887 bool* definitely_mismatches, InvokeFlag flag, |
| 1012 bool* definitely_mismatches, | |
| 1013 InvokeFlag flag, | |
| 1014 Label::Distance done_distance, | 888 Label::Distance done_distance, |
| 1015 const CallWrapper& call_wrapper); | 889 const CallWrapper& call_wrapper); |
| 1016 | 890 |
| 891 void FloodFunctionIfStepping(Register fun, Register new_target, |
| 892 const ParameterCount& expected, |
| 893 const ParameterCount& actual); |
| 894 |
| 1017 void EnterExitFramePrologue(); | 895 void EnterExitFramePrologue(); |
| 1018 void EnterExitFrameEpilogue(int argc, bool save_doubles); | 896 void EnterExitFrameEpilogue(int argc, bool save_doubles); |
| 1019 | 897 |
| 1020 void LeaveExitFrameEpilogue(bool restore_context); | 898 void LeaveExitFrameEpilogue(bool restore_context); |
| 1021 | 899 |
| 1022 // Allocation support helpers. | 900 // Allocation support helpers. |
| 1023 void LoadAllocationTopHelper(Register result, | 901 void LoadAllocationTopHelper(Register result, Register scratch, |
| 1024 Register scratch, | |
| 1025 AllocationFlags flags); | 902 AllocationFlags flags); |
| 1026 | 903 |
| 1027 void UpdateAllocationTopHelper(Register result_end, | 904 void UpdateAllocationTopHelper(Register result_end, Register scratch, |
| 1028 Register scratch, | |
| 1029 AllocationFlags flags); | 905 AllocationFlags flags); |
| 1030 | 906 |
| 1031 // Helper for implementing JumpIfNotInNewSpace and JumpIfInNewSpace. | 907 // Helper for implementing JumpIfNotInNewSpace and JumpIfInNewSpace. |
| 1032 void InNewSpace(Register object, | 908 void InNewSpace(Register object, Register scratch, Condition cc, |
| 1033 Register scratch, | |
| 1034 Condition cc, | |
| 1035 Label* condition_met, | 909 Label* condition_met, |
| 1036 Label::Distance condition_met_distance = Label::kFar); | 910 Label::Distance condition_met_distance = Label::kFar); |
| 1037 | 911 |
| 1038 // Helper for finding the mark bits for an address. Afterwards, the | 912 // Helper for finding the mark bits for an address. Afterwards, the |
| 1039 // bitmap register points at the word with the mark bits and the mask | 913 // bitmap register points at the word with the mark bits and the mask |
| 1040 // the position of the first bit. Uses ecx as scratch and leaves addr_reg | 914 // the position of the first bit. Uses ecx as scratch and leaves addr_reg |
| 1041 // unchanged. | 915 // unchanged. |
| 1042 inline void GetMarkBits(Register addr_reg, | 916 inline void GetMarkBits(Register addr_reg, Register bitmap_reg, |
| 1043 Register bitmap_reg, | |
| 1044 Register mask_reg); | 917 Register mask_reg); |
| 1045 | 918 |
| 1046 // Compute memory operands for safepoint stack slots. | 919 // Compute memory operands for safepoint stack slots. |
| 1047 Operand SafepointRegisterSlot(Register reg); | 920 Operand SafepointRegisterSlot(Register reg); |
| 1048 static int SafepointRegisterStackIndex(int reg_code); | 921 static int SafepointRegisterStackIndex(int reg_code); |
| 1049 | 922 |
| 1050 // Needs access to SafepointRegisterStackIndex for compiled frame | 923 // Needs access to SafepointRegisterStackIndex for compiled frame |
| 1051 // traversal. | 924 // traversal. |
| 1052 friend class StandardFrame; | 925 friend class StandardFrame; |
| 1053 }; | 926 }; |
| 1054 | 927 |
| 1055 | |
| 1056 // The code patcher is used to patch (typically) small parts of code e.g. for | 928 // The code patcher is used to patch (typically) small parts of code e.g. for |
| 1057 // debugging and other types of instrumentation. When using the code patcher | 929 // debugging and other types of instrumentation. When using the code patcher |
| 1058 // the exact number of bytes specified must be emitted. Is not legal to emit | 930 // the exact number of bytes specified must be emitted. Is not legal to emit |
| 1059 // relocation information. If any of these constraints are violated it causes | 931 // relocation information. If any of these constraints are violated it causes |
| 1060 // an assertion. | 932 // an assertion. |
| 1061 class CodePatcher { | 933 class CodePatcher { |
| 1062 public: | 934 public: |
| 1063 CodePatcher(byte* address, int size); | 935 CodePatcher(byte* address, int size); |
| 1064 ~CodePatcher(); | 936 ~CodePatcher(); |
| 1065 | 937 |
| 1066 // Macro assembler to emit code. | 938 // Macro assembler to emit code. |
| 1067 MacroAssembler* masm() { return &masm_; } | 939 MacroAssembler* masm() { return &masm_; } |
| 1068 | 940 |
| 1069 private: | 941 private: |
| 1070 byte* address_; // The address of the code being patched. | 942 byte* address_; // The address of the code being patched. |
| 1071 int size_; // Number of bytes of the expected patch size. | 943 int size_; // Number of bytes of the expected patch size. |
| 1072 MacroAssembler masm_; // Macro assembler used to generate the code. | 944 MacroAssembler masm_; // Macro assembler used to generate the code. |
| 1073 }; | 945 }; |
| 1074 | 946 |
| 1075 | |
| 1076 // ----------------------------------------------------------------------------- | 947 // ----------------------------------------------------------------------------- |
| 1077 // Static helper functions. | 948 // Static helper functions. |
| 1078 | 949 |
| 1079 // Generate an Operand for loading a field from an object. | 950 // Generate an Operand for loading a field from an object. |
| 1080 inline Operand FieldOperand(Register object, int offset) { | 951 inline Operand FieldOperand(Register object, int offset) { |
| 1081 return Operand(object, offset - kHeapObjectTag); | 952 return Operand(object, offset - kHeapObjectTag); |
| 1082 } | 953 } |
| 1083 | 954 |
| 1084 | |
| 1085 // Generate an Operand for loading an indexed field from an object. | 955 // Generate an Operand for loading an indexed field from an object. |
| 1086 inline Operand FieldOperand(Register object, | 956 inline Operand FieldOperand(Register object, Register index, ScaleFactor scale, |
| 1087 Register index, | |
| 1088 ScaleFactor scale, | |
| 1089 int offset) { | 957 int offset) { |
| 1090 return Operand(object, index, scale, offset - kHeapObjectTag); | 958 return Operand(object, index, scale, offset - kHeapObjectTag); |
| 1091 } | 959 } |
| 1092 | 960 |
| 1093 | 961 inline Operand FixedArrayElementOperand(Register array, Register index_as_smi, |
| 1094 inline Operand FixedArrayElementOperand(Register array, | |
| 1095 Register index_as_smi, | |
| 1096 int additional_offset = 0) { | 962 int additional_offset = 0) { |
| 1097 int offset = FixedArray::kHeaderSize + additional_offset * kPointerSize; | 963 int offset = FixedArray::kHeaderSize + additional_offset * kPointerSize; |
| 1098 return FieldOperand(array, index_as_smi, times_half_pointer_size, offset); | 964 return FieldOperand(array, index_as_smi, times_half_pointer_size, offset); |
| 1099 } | 965 } |
| 1100 | 966 |
| 1101 | |
| 1102 inline Operand ContextOperand(Register context, int index) { | 967 inline Operand ContextOperand(Register context, int index) { |
| 1103 return Operand(context, Context::SlotOffset(index)); | 968 return Operand(context, Context::SlotOffset(index)); |
| 1104 } | 969 } |
| 1105 | 970 |
| 1106 | |
| 1107 inline Operand ContextOperand(Register context, Register index) { | 971 inline Operand ContextOperand(Register context, Register index) { |
| 1108 return Operand(context, index, times_pointer_size, Context::SlotOffset(0)); | 972 return Operand(context, index, times_pointer_size, Context::SlotOffset(0)); |
| 1109 } | 973 } |
| 1110 | 974 |
| 1111 | |
| 1112 inline Operand GlobalObjectOperand() { | 975 inline Operand GlobalObjectOperand() { |
| 1113 return ContextOperand(esi, Context::GLOBAL_OBJECT_INDEX); | 976 return ContextOperand(esi, Context::GLOBAL_OBJECT_INDEX); |
| 1114 } | 977 } |
| 1115 | 978 |
| 1116 | |
| 1117 #ifdef GENERATED_CODE_COVERAGE | 979 #ifdef GENERATED_CODE_COVERAGE |
| 1118 extern void LogGeneratedCodeCoverage(const char* file_line); | 980 extern void LogGeneratedCodeCoverage(const char* file_line); |
| 1119 #define CODE_COVERAGE_STRINGIFY(x) #x | 981 #define CODE_COVERAGE_STRINGIFY(x) #x |
| 1120 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 982 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
| 1121 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 983 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
| 1122 #define ACCESS_MASM(masm) { \ | 984 #define ACCESS_MASM(masm) { \ |
| 1123 byte* ia32_coverage_function = \ | 985 byte* ia32_coverage_function = \ |
| 1124 reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage)); \ | 986 reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage)); \ |
| 1125 masm->pushfd(); \ | 987 masm->pushfd(); \ |
| 1126 masm->pushad(); \ | 988 masm->pushad(); \ |
| 1127 masm->push(Immediate(reinterpret_cast<int>(&__FILE_LINE__))); \ | 989 masm->push(Immediate(reinterpret_cast<int>(&__FILE_LINE__))); \ |
| 1128 masm->call(ia32_coverage_function, RelocInfo::RUNTIME_ENTRY); \ | 990 masm->call(ia32_coverage_function, RelocInfo::RUNTIME_ENTRY); \ |
| 1129 masm->pop(eax); \ | 991 masm->pop(eax); \ |
| 1130 masm->popad(); \ | 992 masm->popad(); \ |
| 1131 masm->popfd(); \ | 993 masm->popfd(); \ |
| 1132 } \ | 994 } \ |
| 1133 masm-> | 995 masm-> |
| 1134 #else | 996 #else |
| 1135 #define ACCESS_MASM(masm) masm-> | 997 #define ACCESS_MASM(masm) masm-> |
| 1136 #endif | 998 #endif |
| 1137 | 999 |
| 1138 | |
| 1139 } // namespace internal | 1000 } // namespace internal |
| 1140 } // namespace v8 | 1001 } // namespace v8 |
| 1141 | 1002 |
| 1142 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 1003 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| OLD | NEW |