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_ARGUMENTS_H_ | 5 #ifndef V8_ARGUMENTS_H_ |
6 #define V8_ARGUMENTS_H_ | 6 #define V8_ARGUMENTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/tracing/trace-event.h" | 10 #include "src/tracing/trace-event.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }; | 72 }; |
73 | 73 |
74 double ClobberDoubleRegisters(double x1, double x2, double x3, double x4); | 74 double ClobberDoubleRegisters(double x1, double x2, double x3, double x4); |
75 | 75 |
76 #ifdef DEBUG | 76 #ifdef DEBUG |
77 #define CLOBBER_DOUBLE_REGISTERS() ClobberDoubleRegisters(1, 2, 3, 4); | 77 #define CLOBBER_DOUBLE_REGISTERS() ClobberDoubleRegisters(1, 2, 3, 4); |
78 #else | 78 #else |
79 #define CLOBBER_DOUBLE_REGISTERS() | 79 #define CLOBBER_DOUBLE_REGISTERS() |
80 #endif | 80 #endif |
81 | 81 |
82 #define RUNTIME_FUNCTION_RETURNS_TYPE(Type, Name) \ | 82 // TODO(cbruni): add global flag to check whether any tracing events have been |
83 static INLINE(Type __RT_impl_##Name(Arguments args, Isolate* isolate)); \ | 83 // enabled. |
84 Type Name(int args_length, Object** args_object, Isolate* isolate) { \ | 84 #define RUNTIME_FUNCTION_RETURNS_TYPE(Type, Name) \ |
85 CLOBBER_DOUBLE_REGISTERS(); \ | 85 static INLINE(Type __RT_impl_##Name(Arguments args, Isolate* isolate)); \ |
86 Type value; \ | 86 \ |
87 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), "V8." #Name); \ | 87 V8_NOINLINE static Type Stats_##Name(int args_length, Object** args_object, \ |
88 Arguments args(args_length, args_object); \ | 88 Isolate* isolate) { \ |
89 if (FLAG_runtime_call_stats) { \ | 89 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \ |
90 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \ | 90 RuntimeCallTimerScope timer(isolate, &stats->Name); \ |
91 RuntimeCallTimerScope timer(isolate, &stats->Name); \ | 91 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ |
92 value = __RT_impl_##Name(args, isolate); \ | 92 "V8.Runtime_" #Name); \ |
93 } else { \ | 93 Arguments args(args_length, args_object); \ |
94 value = __RT_impl_##Name(args, isolate); \ | 94 return __RT_impl_##Name(args, isolate); \ |
95 } \ | 95 } \ |
96 return value; \ | 96 \ |
97 } \ | 97 Type Name(int args_length, Object** args_object, Isolate* isolate) { \ |
| 98 CLOBBER_DOUBLE_REGISTERS(); \ |
| 99 if (FLAG_runtime_call_stats) { \ |
| 100 return Stats_##Name(args_length, args_object, isolate); \ |
| 101 } \ |
| 102 Arguments args(args_length, args_object); \ |
| 103 return __RT_impl_##Name(args, isolate); \ |
| 104 } \ |
| 105 \ |
98 static Type __RT_impl_##Name(Arguments args, Isolate* isolate) | 106 static Type __RT_impl_##Name(Arguments args, Isolate* isolate) |
99 | 107 |
100 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name) | 108 #define RUNTIME_FUNCTION(Name) RUNTIME_FUNCTION_RETURNS_TYPE(Object*, Name) |
101 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \ | 109 #define RUNTIME_FUNCTION_RETURN_PAIR(Name) \ |
102 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name) | 110 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectPair, Name) |
103 #define RUNTIME_FUNCTION_RETURN_TRIPLE(Name) \ | 111 #define RUNTIME_FUNCTION_RETURN_TRIPLE(Name) \ |
104 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectTriple, Name) | 112 RUNTIME_FUNCTION_RETURNS_TYPE(ObjectTriple, Name) |
105 | 113 |
106 } // namespace internal | 114 } // namespace internal |
107 } // namespace v8 | 115 } // namespace v8 |
108 | 116 |
109 #endif // V8_ARGUMENTS_H_ | 117 #endif // V8_ARGUMENTS_H_ |
OLD | NEW |