| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 28 #ifndef V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
| 29 #define V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 29 #define V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
| 30 | 30 |
| 31 #include "assembler.h" | 31 #include "assembler.h" |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 // Forward declaration. | 36 // Forward declaration. |
| 37 class PostCallGenerator; | 37 class CallWrapper; |
| 38 | 38 |
| 39 // ---------------------------------------------------------------------------- | 39 // ---------------------------------------------------------------------------- |
| 40 // Static helper functions | 40 // Static helper functions |
| 41 | 41 |
| 42 // Generate a MemOperand for loading a field from an object. | 42 // Generate a MemOperand for loading a field from an object. |
| 43 static inline MemOperand FieldMemOperand(Register object, int offset) { | 43 static inline MemOperand FieldMemOperand(Register object, int offset) { |
| 44 return MemOperand(object, offset - kHeapObjectTag); | 44 return MemOperand(object, offset - kHeapObjectTag); |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // MacroAssembler implements a collection of frequently used macros. | 90 // MacroAssembler implements a collection of frequently used macros. |
| 91 class MacroAssembler: public Assembler { | 91 class MacroAssembler: public Assembler { |
| 92 public: | 92 public: |
| 93 MacroAssembler(void* buffer, int size); | 93 MacroAssembler(void* buffer, int size); |
| 94 | 94 |
| 95 // Jump, Call, and Ret pseudo instructions implementing inter-working. | 95 // Jump, Call, and Ret pseudo instructions implementing inter-working. |
| 96 void Jump(Register target, Condition cond = al); | 96 void Jump(Register target, Condition cond = al); |
| 97 void Jump(byte* target, RelocInfo::Mode rmode, Condition cond = al); | 97 void Jump(byte* target, RelocInfo::Mode rmode, Condition cond = al); |
| 98 void Jump(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al); | 98 void Jump(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al); |
| 99 int CallSize(Register target, Condition cond = al); |
| 99 void Call(Register target, Condition cond = al); | 100 void Call(Register target, Condition cond = al); |
| 101 int CallSize(byte* target, RelocInfo::Mode rmode, Condition cond = al); |
| 100 void Call(byte* target, RelocInfo::Mode rmode, Condition cond = al); | 102 void Call(byte* target, RelocInfo::Mode rmode, Condition cond = al); |
| 103 int CallSize(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al); |
| 101 void Call(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al); | 104 void Call(Handle<Code> code, RelocInfo::Mode rmode, Condition cond = al); |
| 102 void Ret(Condition cond = al); | 105 void Ret(Condition cond = al); |
| 103 | 106 |
| 104 // Emit code to discard a non-negative number of pointer-sized elements | 107 // Emit code to discard a non-negative number of pointer-sized elements |
| 105 // from the stack, clobbering only the sp register. | 108 // from the stack, clobbering only the sp register. |
| 106 void Drop(int count, Condition cond = al); | 109 void Drop(int count, Condition cond = al); |
| 107 | 110 |
| 108 void Ret(int drop, Condition cond = al); | 111 void Ret(int drop, Condition cond = al); |
| 109 | 112 |
| 110 // Swap two registers. If the scratch register is omitted then a slightly | 113 // Swap two registers. If the scratch register is omitted then a slightly |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 Register scratch); | 339 Register scratch); |
| 337 | 340 |
| 338 // --------------------------------------------------------------------------- | 341 // --------------------------------------------------------------------------- |
| 339 // JavaScript invokes | 342 // JavaScript invokes |
| 340 | 343 |
| 341 // Invoke the JavaScript function code by either calling or jumping. | 344 // Invoke the JavaScript function code by either calling or jumping. |
| 342 void InvokeCode(Register code, | 345 void InvokeCode(Register code, |
| 343 const ParameterCount& expected, | 346 const ParameterCount& expected, |
| 344 const ParameterCount& actual, | 347 const ParameterCount& actual, |
| 345 InvokeFlag flag, | 348 InvokeFlag flag, |
| 346 PostCallGenerator* post_call_generator = NULL); | 349 CallWrapper* call_wrapper = NULL); |
| 347 | 350 |
| 348 void InvokeCode(Handle<Code> code, | 351 void InvokeCode(Handle<Code> code, |
| 349 const ParameterCount& expected, | 352 const ParameterCount& expected, |
| 350 const ParameterCount& actual, | 353 const ParameterCount& actual, |
| 351 RelocInfo::Mode rmode, | 354 RelocInfo::Mode rmode, |
| 352 InvokeFlag flag); | 355 InvokeFlag flag); |
| 353 | 356 |
| 354 // Invoke the JavaScript function in the given register. Changes the | 357 // Invoke the JavaScript function in the given register. Changes the |
| 355 // current context to the context in the function before invoking. | 358 // current context to the context in the function before invoking. |
| 356 void InvokeFunction(Register function, | 359 void InvokeFunction(Register function, |
| 357 const ParameterCount& actual, | 360 const ParameterCount& actual, |
| 358 InvokeFlag flag, | 361 InvokeFlag flag, |
| 359 PostCallGenerator* post_call_generator = NULL); | 362 CallWrapper* call_wrapper = NULL); |
| 360 | 363 |
| 361 void InvokeFunction(JSFunction* function, | 364 void InvokeFunction(JSFunction* function, |
| 362 const ParameterCount& actual, | 365 const ParameterCount& actual, |
| 363 InvokeFlag flag); | 366 InvokeFlag flag); |
| 364 | 367 |
| 365 void IsObjectJSObjectType(Register heap_object, | 368 void IsObjectJSObjectType(Register heap_object, |
| 366 Register map, | 369 Register map, |
| 367 Register scratch, | 370 Register scratch, |
| 368 Label* fail); | 371 Label* fail); |
| 369 | 372 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 744 |
| 742 // Jump to a runtime routine. | 745 // Jump to a runtime routine. |
| 743 void JumpToExternalReference(const ExternalReference& builtin); | 746 void JumpToExternalReference(const ExternalReference& builtin); |
| 744 | 747 |
| 745 MaybeObject* TryJumpToExternalReference(const ExternalReference& ext); | 748 MaybeObject* TryJumpToExternalReference(const ExternalReference& ext); |
| 746 | 749 |
| 747 // Invoke specified builtin JavaScript function. Adds an entry to | 750 // Invoke specified builtin JavaScript function. Adds an entry to |
| 748 // the unresolved list if the name does not resolve. | 751 // the unresolved list if the name does not resolve. |
| 749 void InvokeBuiltin(Builtins::JavaScript id, | 752 void InvokeBuiltin(Builtins::JavaScript id, |
| 750 InvokeJSFlags flags, | 753 InvokeJSFlags flags, |
| 751 PostCallGenerator* post_call_generator = NULL); | 754 CallWrapper* call_wrapper = NULL); |
| 752 | 755 |
| 753 // Store the code object for the given builtin in the target register and | 756 // Store the code object for the given builtin in the target register and |
| 754 // setup the function in r1. | 757 // setup the function in r1. |
| 755 void GetBuiltinEntry(Register target, Builtins::JavaScript id); | 758 void GetBuiltinEntry(Register target, Builtins::JavaScript id); |
| 756 | 759 |
| 757 // Store the function for the given builtin in the target register. | 760 // Store the function for the given builtin in the target register. |
| 758 void GetBuiltinFunction(Register target, Builtins::JavaScript id); | 761 void GetBuiltinFunction(Register target, Builtins::JavaScript id); |
| 759 | 762 |
| 760 Handle<Object> CodeObject() { return code_object_; } | 763 Handle<Object> CodeObject() { return code_object_; } |
| 761 | 764 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 Register result); | 912 Register result); |
| 910 | 913 |
| 911 | 914 |
| 912 private: | 915 private: |
| 913 void CallCFunctionHelper(Register function, | 916 void CallCFunctionHelper(Register function, |
| 914 ExternalReference function_reference, | 917 ExternalReference function_reference, |
| 915 Register scratch, | 918 Register scratch, |
| 916 int num_arguments); | 919 int num_arguments); |
| 917 | 920 |
| 918 void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); | 921 void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
| 922 int CallSize(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
| 919 void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); | 923 void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
| 920 | 924 |
| 921 // Helper functions for generating invokes. | 925 // Helper functions for generating invokes. |
| 922 void InvokePrologue(const ParameterCount& expected, | 926 void InvokePrologue(const ParameterCount& expected, |
| 923 const ParameterCount& actual, | 927 const ParameterCount& actual, |
| 924 Handle<Code> code_constant, | 928 Handle<Code> code_constant, |
| 925 Register code_reg, | 929 Register code_reg, |
| 926 Label* done, | 930 Label* done, |
| 927 InvokeFlag flag, | 931 InvokeFlag flag, |
| 928 PostCallGenerator* post_call_generator = NULL); | 932 CallWrapper* call_wrapper = NULL); |
| 929 | 933 |
| 930 // Activation support. | 934 // Activation support. |
| 931 void EnterFrame(StackFrame::Type type); | 935 void EnterFrame(StackFrame::Type type); |
| 932 void LeaveFrame(StackFrame::Type type); | 936 void LeaveFrame(StackFrame::Type type); |
| 933 | 937 |
| 934 void InitializeNewString(Register string, | 938 void InitializeNewString(Register string, |
| 935 Register length, | 939 Register length, |
| 936 Heap::RootListIndex map_index, | 940 Heap::RootListIndex map_index, |
| 937 Register scratch1, | 941 Register scratch1, |
| 938 Register scratch2); | 942 Register scratch2); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 int instructions_; // Number of instructions of the expected patch size. | 986 int instructions_; // Number of instructions of the expected patch size. |
| 983 int size_; // Number of bytes of the expected patch size. | 987 int size_; // Number of bytes of the expected patch size. |
| 984 MacroAssembler masm_; // Macro assembler used to generate the code. | 988 MacroAssembler masm_; // Macro assembler used to generate the code. |
| 985 }; | 989 }; |
| 986 #endif // ENABLE_DEBUGGER_SUPPORT | 990 #endif // ENABLE_DEBUGGER_SUPPORT |
| 987 | 991 |
| 988 | 992 |
| 989 // Helper class for generating code or data associated with the code | 993 // Helper class for generating code or data associated with the code |
| 990 // right after a call instruction. As an example this can be used to | 994 // right after a call instruction. As an example this can be used to |
| 991 // generate safepoint data after calls for crankshaft. | 995 // generate safepoint data after calls for crankshaft. |
| 992 class PostCallGenerator { | 996 class CallWrapper { |
| 993 public: | 997 public: |
| 994 PostCallGenerator() { } | 998 CallWrapper() { } |
| 995 virtual ~PostCallGenerator() { } | 999 virtual ~CallWrapper() { } |
| 996 virtual void Generate() = 0; | 1000 // Called just before emitting a call. Argument is the size of the generated |
| 1001 // call code. |
| 1002 virtual void BeforeCall(int call_size) = 0; |
| 1003 // Called just after emitting a call, i.e., at the return site for the call. |
| 1004 virtual void AfterCall() = 0; |
| 997 }; | 1005 }; |
| 998 | 1006 |
| 999 | 1007 |
| 1000 // ----------------------------------------------------------------------------- | 1008 // ----------------------------------------------------------------------------- |
| 1001 // Static helper functions. | 1009 // Static helper functions. |
| 1002 | 1010 |
| 1003 static MemOperand ContextOperand(Register context, int index) { | 1011 static MemOperand ContextOperand(Register context, int index) { |
| 1004 return MemOperand(context, Context::SlotOffset(index)); | 1012 return MemOperand(context, Context::SlotOffset(index)); |
| 1005 } | 1013 } |
| 1006 | 1014 |
| 1007 | 1015 |
| 1008 static inline MemOperand GlobalObjectOperand() { | 1016 static inline MemOperand GlobalObjectOperand() { |
| 1009 return ContextOperand(cp, Context::GLOBAL_INDEX); | 1017 return ContextOperand(cp, Context::GLOBAL_INDEX); |
| 1010 } | 1018 } |
| 1011 | 1019 |
| 1012 | 1020 |
| 1013 #ifdef GENERATED_CODE_COVERAGE | 1021 #ifdef GENERATED_CODE_COVERAGE |
| 1014 #define CODE_COVERAGE_STRINGIFY(x) #x | 1022 #define CODE_COVERAGE_STRINGIFY(x) #x |
| 1015 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 1023 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
| 1016 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1024 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
| 1017 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> | 1025 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> |
| 1018 #else | 1026 #else |
| 1019 #define ACCESS_MASM(masm) masm-> | 1027 #define ACCESS_MASM(masm) masm-> |
| 1020 #endif | 1028 #endif |
| 1021 | 1029 |
| 1022 | 1030 |
| 1023 } } // namespace v8::internal | 1031 } } // namespace v8::internal |
| 1024 | 1032 |
| 1025 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 1033 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
| OLD | NEW |