OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 DoTrace(fp); | 86 DoTrace(fp); |
87 *(CcTest::i_isolate()->c_entry_fp_address()) = saved_c_frame_fp; | 87 *(CcTest::i_isolate()->c_entry_fp_address()) = saved_c_frame_fp; |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 // --- T r a c e E x t e n s i o n --- | 91 // --- T r a c e E x t e n s i o n --- |
92 | 92 |
93 class TraceExtension : public v8::Extension { | 93 class TraceExtension : public v8::Extension { |
94 public: | 94 public: |
95 TraceExtension() : v8::Extension("v8/trace", kSource) { } | 95 TraceExtension() : v8::Extension("v8/trace", kSource) { } |
96 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 96 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 97 v8::Isolate* isolate, |
97 v8::Handle<String> name); | 98 v8::Handle<String> name); |
98 static void Trace(const v8::FunctionCallbackInfo<v8::Value>& args); | 99 static void Trace(const v8::FunctionCallbackInfo<v8::Value>& args); |
99 static void JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args); | 100 static void JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args); |
100 static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args); | 101 static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args); |
101 static void JSEntrySPLevel2(const v8::FunctionCallbackInfo<v8::Value>& args); | 102 static void JSEntrySPLevel2(const v8::FunctionCallbackInfo<v8::Value>& args); |
102 private: | 103 private: |
103 static Address GetFP(const v8::FunctionCallbackInfo<v8::Value>& args); | 104 static Address GetFP(const v8::FunctionCallbackInfo<v8::Value>& args); |
104 static const char* kSource; | 105 static const char* kSource; |
105 }; | 106 }; |
106 | 107 |
107 | 108 |
108 const char* TraceExtension::kSource = | 109 const char* TraceExtension::kSource = |
109 "native function trace();" | 110 "native function trace();" |
110 "native function js_trace();" | 111 "native function js_trace();" |
111 "native function js_entry_sp();" | 112 "native function js_entry_sp();" |
112 "native function js_entry_sp_level2();"; | 113 "native function js_entry_sp_level2();"; |
113 | 114 |
114 v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunction( | 115 v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate( |
115 v8::Handle<String> name) { | 116 v8::Isolate* isolate, v8::Handle<String> name) { |
116 if (name->Equals(String::NewFromUtf8(v8::Isolate::GetCurrent(), "trace"))) { | 117 if (name->Equals(String::NewFromUtf8(isolate, "trace"))) { |
117 return v8::FunctionTemplate::New(TraceExtension::Trace); | 118 return v8::FunctionTemplate::New(TraceExtension::Trace); |
118 } else if (name->Equals( | 119 } else if (name->Equals( |
119 String::NewFromUtf8(v8::Isolate::GetCurrent(), "js_trace"))) { | 120 String::NewFromUtf8(isolate, "js_trace"))) { |
120 return v8::FunctionTemplate::New(TraceExtension::JSTrace); | 121 return v8::FunctionTemplate::New(TraceExtension::JSTrace); |
121 } else if (name->Equals(String::NewFromUtf8(v8::Isolate::GetCurrent(), | 122 } else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp"))) { |
122 "js_entry_sp"))) { | |
123 return v8::FunctionTemplate::New(TraceExtension::JSEntrySP); | 123 return v8::FunctionTemplate::New(TraceExtension::JSEntrySP); |
124 } else if (name->Equals(String::NewFromUtf8(v8::Isolate::GetCurrent(), | 124 } else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp_level2"))) { |
125 "js_entry_sp_level2"))) { | |
126 return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2); | 125 return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2); |
127 } else { | 126 } else { |
128 CHECK(false); | 127 CHECK(false); |
129 return v8::Handle<v8::FunctionTemplate>(); | 128 return v8::Handle<v8::FunctionTemplate>(); |
130 } | 129 } |
131 } | 130 } |
132 | 131 |
133 | 132 |
134 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { | 133 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { |
135 // Convert frame pointer from encoding as smis in the arguments to a pointer. | 134 // Convert frame pointer from encoding as smis in the arguments to a pointer. |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION); | 404 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION); |
406 v8::Context::Scope context_scope(context); | 405 v8::Context::Scope context_scope(context); |
407 CHECK_EQ(0, GetJsEntrySp()); | 406 CHECK_EQ(0, GetJsEntrySp()); |
408 CompileRun("a = 1; b = a + 1;"); | 407 CompileRun("a = 1; b = a + 1;"); |
409 CHECK_EQ(0, GetJsEntrySp()); | 408 CHECK_EQ(0, GetJsEntrySp()); |
410 CompileRun("js_entry_sp();"); | 409 CompileRun("js_entry_sp();"); |
411 CHECK_EQ(0, GetJsEntrySp()); | 410 CHECK_EQ(0, GetJsEntrySp()); |
412 CompileRun("js_entry_sp_level2();"); | 411 CompileRun("js_entry_sp_level2();"); |
413 CHECK_EQ(0, GetJsEntrySp()); | 412 CHECK_EQ(0, GetJsEntrySp()); |
414 } | 413 } |
OLD | NEW |