| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // --------------------------------------------------------------------------- | 62 // --------------------------------------------------------------------------- |
| 63 // Debugger Support | 63 // Debugger Support |
| 64 | 64 |
| 65 void SaveRegistersToMemory(RegList regs); | 65 void SaveRegistersToMemory(RegList regs); |
| 66 void RestoreRegistersFromMemory(RegList regs); | 66 void RestoreRegistersFromMemory(RegList regs); |
| 67 void PushRegistersFromMemory(RegList regs); | 67 void PushRegistersFromMemory(RegList regs); |
| 68 void PopRegistersToMemory(RegList regs); | 68 void PopRegistersToMemory(RegList regs); |
| 69 void CopyRegistersFromStackToMemory(Register base, | 69 void CopyRegistersFromStackToMemory(Register base, |
| 70 Register scratch, | 70 Register scratch, |
| 71 RegList regs); | 71 RegList regs); |
| 72 void DebugBreak(); |
| 72 #endif | 73 #endif |
| 73 | 74 |
| 74 // --------------------------------------------------------------------------- | 75 // --------------------------------------------------------------------------- |
| 75 // Stack limit support | 76 // Stack limit support |
| 76 | 77 |
| 77 // Do simple test for stack overflow. This doesn't handle an overflow. | 78 // Do simple test for stack overflow. This doesn't handle an overflow. |
| 78 void StackLimitCheck(Label* on_stack_limit_hit); | 79 void StackLimitCheck(Label* on_stack_limit_hit); |
| 79 | 80 |
| 80 // --------------------------------------------------------------------------- | 81 // --------------------------------------------------------------------------- |
| 81 // Activation frames | 82 // Activation frames |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 const ParameterCount& actual, | 117 const ParameterCount& actual, |
| 117 RelocInfo::Mode rmode, | 118 RelocInfo::Mode rmode, |
| 118 InvokeFlag flag); | 119 InvokeFlag flag); |
| 119 | 120 |
| 120 // Invoke the JavaScript function in the given register. Changes the | 121 // Invoke the JavaScript function in the given register. Changes the |
| 121 // current context to the context in the function before invoking. | 122 // current context to the context in the function before invoking. |
| 122 void InvokeFunction(Register function, | 123 void InvokeFunction(Register function, |
| 123 const ParameterCount& actual, | 124 const ParameterCount& actual, |
| 124 InvokeFlag flag); | 125 InvokeFlag flag); |
| 125 | 126 |
| 127 void InvokeFunction(JSFunction* function, |
| 128 const ParameterCount& actual, |
| 129 InvokeFlag flag); |
| 130 |
| 126 // Invoke specified builtin JavaScript function. Adds an entry to | 131 // Invoke specified builtin JavaScript function. Adds an entry to |
| 127 // the unresolved list if the name does not resolve. | 132 // the unresolved list if the name does not resolve. |
| 128 void InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag); | 133 void InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag); |
| 129 | 134 |
| 130 // Store the code object for the given builtin in the target register. | 135 // Store the code object for the given builtin in the target register. |
| 131 void GetBuiltinEntry(Register target, Builtins::JavaScript id); | 136 void GetBuiltinEntry(Register target, Builtins::JavaScript id); |
| 132 | 137 |
| 133 // Expression support | 138 // Expression support |
| 134 void Set(Register dst, const Immediate& x); | 139 void Set(Register dst, const Immediate& x); |
| 135 void Set(const Operand& dst, const Immediate& x); | 140 void Set(const Operand& dst, const Immediate& x); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 164 | 169 |
| 165 // Smi tagging support. | 170 // Smi tagging support. |
| 166 void SmiTag(Register reg) { | 171 void SmiTag(Register reg) { |
| 167 ASSERT(kSmiTag == 0); | 172 ASSERT(kSmiTag == 0); |
| 168 shl(reg, kSmiTagSize); | 173 shl(reg, kSmiTagSize); |
| 169 } | 174 } |
| 170 void SmiUntag(Register reg) { | 175 void SmiUntag(Register reg) { |
| 171 sar(reg, kSmiTagSize); | 176 sar(reg, kSmiTagSize); |
| 172 } | 177 } |
| 173 | 178 |
| 179 // Abort execution if argument is not a number. Used in debug code. |
| 180 void AbortIfNotNumber(Register object, const char* msg); |
| 181 |
| 174 // --------------------------------------------------------------------------- | 182 // --------------------------------------------------------------------------- |
| 175 // Exception handling | 183 // Exception handling |
| 176 | 184 |
| 177 // Push a new try handler and link into try handler chain. The return | 185 // Push a new try handler and link into try handler chain. The return |
| 178 // address must be pushed before calling this helper. | 186 // address must be pushed before calling this helper. |
| 179 void PushTryHandler(CodeLocation try_location, HandlerType type); | 187 void PushTryHandler(CodeLocation try_location, HandlerType type); |
| 180 | 188 |
| 181 // Unlink the stack handler on top of the stack from the try handler chain. | 189 // Unlink the stack handler on top of the stack from the try handler chain. |
| 182 void PopTryHandler(); | 190 void PopTryHandler(); |
| 183 | 191 |
| 184 // --------------------------------------------------------------------------- | 192 // --------------------------------------------------------------------------- |
| 185 // Inline caching support | 193 // Inline caching support |
| 186 | 194 |
| 187 // Generates code that verifies that the maps of objects in the | 195 // Generates code that verifies that the maps of objects in the |
| 188 // prototype chain of object hasn't changed since the code was | 196 // prototype chain of object hasn't changed since the code was |
| 189 // generated and branches to the miss label if any map has. If | 197 // generated and branches to the miss label if any map has. If |
| 190 // necessary the function also generates code for security check | 198 // necessary the function also generates code for security check |
| 191 // in case of global object holders. The scratch and holder | 199 // in case of global object holders. The scratch and holder |
| 192 // registers are always clobbered, but the object register is only | 200 // registers are always clobbered, but the object register is only |
| 193 // clobbered if it the same as the holder register. The function | 201 // clobbered if it the same as the holder register. The function |
| 194 // returns a register containing the holder - either object_reg or | 202 // returns a register containing the holder - either object_reg or |
| 195 // holder_reg. | 203 // holder_reg. |
| 204 // The function can optionally (when save_at_depth != |
| 205 // kInvalidProtoDepth) save the object at the given depth by moving |
| 206 // it to [esp + kPointerSize]. |
| 196 Register CheckMaps(JSObject* object, Register object_reg, | 207 Register CheckMaps(JSObject* object, Register object_reg, |
| 197 JSObject* holder, Register holder_reg, | 208 JSObject* holder, Register holder_reg, |
| 198 Register scratch, Label* miss); | 209 Register scratch, |
| 210 int save_at_depth, |
| 211 Label* miss); |
| 199 | 212 |
| 200 // Generate code for checking access rights - used for security checks | 213 // Generate code for checking access rights - used for security checks |
| 201 // on access to global objects across environments. The holder register | 214 // on access to global objects across environments. The holder register |
| 202 // is left untouched, but the scratch register is clobbered. | 215 // is left untouched, but the scratch register is clobbered. |
| 203 void CheckAccessGlobalProxy(Register holder_reg, | 216 void CheckAccessGlobalProxy(Register holder_reg, |
| 204 Register scratch, | 217 Register scratch, |
| 205 Label* miss); | 218 Label* miss); |
| 206 | 219 |
| 207 | 220 |
| 208 // --------------------------------------------------------------------------- | 221 // --------------------------------------------------------------------------- |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 void CallRuntime(Runtime::Function* f, int num_arguments); | 353 void CallRuntime(Runtime::Function* f, int num_arguments); |
| 341 | 354 |
| 342 // Call a runtime function, returning the CodeStub object called. | 355 // Call a runtime function, returning the CodeStub object called. |
| 343 // Try to generate the stub code if necessary. Do not perform a GC | 356 // Try to generate the stub code if necessary. Do not perform a GC |
| 344 // but instead return a retry after GC failure. | 357 // but instead return a retry after GC failure. |
| 345 Object* TryCallRuntime(Runtime::Function* f, int num_arguments); | 358 Object* TryCallRuntime(Runtime::Function* f, int num_arguments); |
| 346 | 359 |
| 347 // Convenience function: Same as above, but takes the fid instead. | 360 // Convenience function: Same as above, but takes the fid instead. |
| 348 void CallRuntime(Runtime::FunctionId id, int num_arguments); | 361 void CallRuntime(Runtime::FunctionId id, int num_arguments); |
| 349 | 362 |
| 363 // Convenience function: call an external reference. |
| 364 void CallExternalReference(ExternalReference ref, int num_arguments); |
| 365 |
| 350 // Convenience function: Same as above, but takes the fid instead. | 366 // Convenience function: Same as above, but takes the fid instead. |
| 351 Object* TryCallRuntime(Runtime::FunctionId id, int num_arguments); | 367 Object* TryCallRuntime(Runtime::FunctionId id, int num_arguments); |
| 352 | 368 |
| 353 // Tail call of a runtime routine (jump). | 369 // Tail call of a runtime routine (jump). |
| 354 // Like JumpToRuntime, but also takes care of passing the number | 370 // Like JumpToRuntime, but also takes care of passing the number |
| 355 // of arguments. | 371 // of arguments. |
| 356 void TailCallRuntime(const ExternalReference& ext, | 372 void TailCallRuntime(const ExternalReference& ext, |
| 357 int num_arguments, | 373 int num_arguments, |
| 358 int result_size); | 374 int result_size); |
| 359 | 375 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 377 void Ret(); | 393 void Ret(); |
| 378 | 394 |
| 379 // Emit code to discard a non-negative number of pointer-sized elements | 395 // Emit code to discard a non-negative number of pointer-sized elements |
| 380 // from the stack, clobbering only the esp register. | 396 // from the stack, clobbering only the esp register. |
| 381 void Drop(int element_count); | 397 void Drop(int element_count); |
| 382 | 398 |
| 383 void Call(Label* target) { call(target); } | 399 void Call(Label* target) { call(target); } |
| 384 | 400 |
| 385 void Move(Register target, Handle<Object> value); | 401 void Move(Register target, Handle<Object> value); |
| 386 | 402 |
| 387 struct Unresolved { | |
| 388 int pc; | |
| 389 uint32_t flags; // see Bootstrapper::FixupFlags decoders/encoders. | |
| 390 const char* name; | |
| 391 }; | |
| 392 List<Unresolved>* unresolved() { return &unresolved_; } | |
| 393 | |
| 394 Handle<Object> CodeObject() { return code_object_; } | 403 Handle<Object> CodeObject() { return code_object_; } |
| 395 | 404 |
| 396 | 405 |
| 397 // --------------------------------------------------------------------------- | 406 // --------------------------------------------------------------------------- |
| 398 // StatsCounter support | 407 // StatsCounter support |
| 399 | 408 |
| 400 void SetCounter(StatsCounter* counter, int value); | 409 void SetCounter(StatsCounter* counter, int value); |
| 401 void IncrementCounter(StatsCounter* counter, int value); | 410 void IncrementCounter(StatsCounter* counter, int value); |
| 402 void DecrementCounter(StatsCounter* counter, int value); | 411 void DecrementCounter(StatsCounter* counter, int value); |
| 403 void IncrementCounter(Condition cc, StatsCounter* counter, int value); | 412 void IncrementCounter(Condition cc, StatsCounter* counter, int value); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 419 | 428 |
| 420 // Verify restrictions about code generated in stubs. | 429 // Verify restrictions about code generated in stubs. |
| 421 void set_generating_stub(bool value) { generating_stub_ = value; } | 430 void set_generating_stub(bool value) { generating_stub_ = value; } |
| 422 bool generating_stub() { return generating_stub_; } | 431 bool generating_stub() { return generating_stub_; } |
| 423 void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } | 432 void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; } |
| 424 bool allow_stub_calls() { return allow_stub_calls_; } | 433 bool allow_stub_calls() { return allow_stub_calls_; } |
| 425 | 434 |
| 426 // --------------------------------------------------------------------------- | 435 // --------------------------------------------------------------------------- |
| 427 // String utilities. | 436 // String utilities. |
| 428 | 437 |
| 438 // Check whether the instance type represents a flat ascii string. Jump to the |
| 439 // label if not. If the instance type can be scratched specify same register |
| 440 // for both instance type and scratch. |
| 441 void JumpIfInstanceTypeIsNotSequentialAscii(Register instance_type, |
| 442 Register scratch, |
| 443 Label *on_not_flat_ascii_string); |
| 444 |
| 429 // Checks if both objects are sequential ASCII strings, and jumps to label | 445 // Checks if both objects are sequential ASCII strings, and jumps to label |
| 430 // if either is not. | 446 // if either is not. |
| 431 void JumpIfNotBothSequentialAsciiStrings(Register object1, | 447 void JumpIfNotBothSequentialAsciiStrings(Register object1, |
| 432 Register object2, | 448 Register object2, |
| 433 Register scratch1, | 449 Register scratch1, |
| 434 Register scratch2, | 450 Register scratch2, |
| 435 Label *on_not_flat_ascii_strings); | 451 Label *on_not_flat_ascii_strings); |
| 436 | 452 |
| 437 private: | 453 private: |
| 438 List<Unresolved> unresolved_; | |
| 439 bool generating_stub_; | 454 bool generating_stub_; |
| 440 bool allow_stub_calls_; | 455 bool allow_stub_calls_; |
| 441 // This handle will be patched with the code object on installation. | 456 // This handle will be patched with the code object on installation. |
| 442 Handle<Object> code_object_; | 457 Handle<Object> code_object_; |
| 443 | 458 |
| 444 // Helper functions for generating invokes. | 459 // Helper functions for generating invokes. |
| 445 void InvokePrologue(const ParameterCount& expected, | 460 void InvokePrologue(const ParameterCount& expected, |
| 446 const ParameterCount& actual, | 461 const ParameterCount& actual, |
| 447 Handle<Code> code_constant, | 462 Handle<Code> code_constant, |
| 448 const Operand& code_operand, | 463 const Operand& code_operand, |
| 449 Label* done, | 464 Label* done, |
| 450 InvokeFlag flag); | 465 InvokeFlag flag); |
| 451 | 466 |
| 452 // Prepares for a call or jump to a builtin by doing two things: | |
| 453 // 1. Emits code that fetches the builtin's function object from the context | |
| 454 // at runtime, and puts it in the register rdi. | |
| 455 // 2. Fetches the builtin's code object, and returns it in a handle, at | |
| 456 // compile time, so that later code can emit instructions to jump or call | |
| 457 // the builtin directly. If the code object has not yet been created, it | |
| 458 // returns the builtin code object for IllegalFunction, and sets the | |
| 459 // output parameter "resolved" to false. Code that uses the return value | |
| 460 // should then add the address and the builtin name to the list of fixups | |
| 461 // called unresolved_, which is fixed up by the bootstrapper. | |
| 462 Handle<Code> ResolveBuiltin(Builtins::JavaScript id, bool* resolved); | |
| 463 | |
| 464 // Activation support. | 467 // Activation support. |
| 465 void EnterFrame(StackFrame::Type type); | 468 void EnterFrame(StackFrame::Type type); |
| 466 void LeaveFrame(StackFrame::Type type); | 469 void LeaveFrame(StackFrame::Type type); |
| 467 | 470 |
| 468 void EnterExitFramePrologue(ExitFrame::Mode mode); | 471 void EnterExitFramePrologue(ExitFrame::Mode mode); |
| 469 void EnterExitFrameEpilogue(ExitFrame::Mode mode, int argc); | 472 void EnterExitFrameEpilogue(ExitFrame::Mode mode, int argc); |
| 470 | 473 |
| 471 // Allocation support helpers. | 474 // Allocation support helpers. |
| 472 void LoadAllocationTopHelper(Register result, | 475 void LoadAllocationTopHelper(Register result, |
| 473 Register result_end, | 476 Register result_end, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } \ | 543 } \ |
| 541 masm-> | 544 masm-> |
| 542 #else | 545 #else |
| 543 #define ACCESS_MASM(masm) masm-> | 546 #define ACCESS_MASM(masm) masm-> |
| 544 #endif | 547 #endif |
| 545 | 548 |
| 546 | 549 |
| 547 } } // namespace v8::internal | 550 } } // namespace v8::internal |
| 548 | 551 |
| 549 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 552 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| OLD | NEW |