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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 // Patching helpers. | 907 // Patching helpers. |
905 | 908 |
906 // Get the location of a relocated constant (its address in the constant pool) | 909 // Get the location of a relocated constant (its address in the constant pool) |
907 // from its load site. | 910 // from its load site. |
908 void GetRelocatedValueLocation(Register ldr_location, | 911 void GetRelocatedValueLocation(Register ldr_location, |
909 Register result); | 912 Register result); |
910 | 913 |
911 | 914 |
912 private: | 915 private: |
913 void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); | 916 void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
| 917 int CallSize(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
914 void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); | 918 void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = al); |
915 | 919 |
916 // Helper functions for generating invokes. | 920 // Helper functions for generating invokes. |
917 void InvokePrologue(const ParameterCount& expected, | 921 void InvokePrologue(const ParameterCount& expected, |
918 const ParameterCount& actual, | 922 const ParameterCount& actual, |
919 Handle<Code> code_constant, | 923 Handle<Code> code_constant, |
920 Register code_reg, | 924 Register code_reg, |
921 Label* done, | 925 Label* done, |
922 InvokeFlag flag, | 926 InvokeFlag flag, |
923 PostCallGenerator* post_call_generator = NULL); | 927 CallWrapper* call_wrapper = NULL); |
924 | 928 |
925 // Activation support. | 929 // Activation support. |
926 void EnterFrame(StackFrame::Type type); | 930 void EnterFrame(StackFrame::Type type); |
927 void LeaveFrame(StackFrame::Type type); | 931 void LeaveFrame(StackFrame::Type type); |
928 | 932 |
929 void InitializeNewString(Register string, | 933 void InitializeNewString(Register string, |
930 Register length, | 934 Register length, |
931 Heap::RootListIndex map_index, | 935 Heap::RootListIndex map_index, |
932 Register scratch1, | 936 Register scratch1, |
933 Register scratch2); | 937 Register scratch2); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 int instructions_; // Number of instructions of the expected patch size. | 981 int instructions_; // Number of instructions of the expected patch size. |
978 int size_; // Number of bytes of the expected patch size. | 982 int size_; // Number of bytes of the expected patch size. |
979 MacroAssembler masm_; // Macro assembler used to generate the code. | 983 MacroAssembler masm_; // Macro assembler used to generate the code. |
980 }; | 984 }; |
981 #endif // ENABLE_DEBUGGER_SUPPORT | 985 #endif // ENABLE_DEBUGGER_SUPPORT |
982 | 986 |
983 | 987 |
984 // Helper class for generating code or data associated with the code | 988 // Helper class for generating code or data associated with the code |
985 // right after a call instruction. As an example this can be used to | 989 // right after a call instruction. As an example this can be used to |
986 // generate safepoint data after calls for crankshaft. | 990 // generate safepoint data after calls for crankshaft. |
987 class PostCallGenerator { | 991 class CallWrapper { |
988 public: | 992 public: |
989 PostCallGenerator() { } | 993 CallWrapper() { } |
990 virtual ~PostCallGenerator() { } | 994 virtual ~CallWrapper() { } |
991 virtual void Generate() = 0; | 995 // Called just before emitting a call. Argument is the size of the generated |
| 996 // call code. |
| 997 virtual void BeforeCall(int call_size) = 0; |
| 998 // Called just after emitting a call, i.e., at the return site for the call. |
| 999 virtual void AfterCall() = 0; |
992 }; | 1000 }; |
993 | 1001 |
994 | 1002 |
995 // ----------------------------------------------------------------------------- | 1003 // ----------------------------------------------------------------------------- |
996 // Static helper functions. | 1004 // Static helper functions. |
997 | 1005 |
998 static MemOperand ContextOperand(Register context, int index) { | 1006 static MemOperand ContextOperand(Register context, int index) { |
999 return MemOperand(context, Context::SlotOffset(index)); | 1007 return MemOperand(context, Context::SlotOffset(index)); |
1000 } | 1008 } |
1001 | 1009 |
1002 | 1010 |
1003 static inline MemOperand GlobalObjectOperand() { | 1011 static inline MemOperand GlobalObjectOperand() { |
1004 return ContextOperand(cp, Context::GLOBAL_INDEX); | 1012 return ContextOperand(cp, Context::GLOBAL_INDEX); |
1005 } | 1013 } |
1006 | 1014 |
1007 | 1015 |
1008 #ifdef GENERATED_CODE_COVERAGE | 1016 #ifdef GENERATED_CODE_COVERAGE |
1009 #define CODE_COVERAGE_STRINGIFY(x) #x | 1017 #define CODE_COVERAGE_STRINGIFY(x) #x |
1010 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 1018 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
1011 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 1019 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
1012 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> | 1020 #define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm-> |
1013 #else | 1021 #else |
1014 #define ACCESS_MASM(masm) masm-> | 1022 #define ACCESS_MASM(masm) masm-> |
1015 #endif | 1023 #endif |
1016 | 1024 |
1017 | 1025 |
1018 } } // namespace v8::internal | 1026 } } // namespace v8::internal |
1019 | 1027 |
1020 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ | 1028 #endif // V8_ARM_MACRO_ASSEMBLER_ARM_H_ |
OLD | NEW |