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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 const char* TraceExtension::kSource = | 109 const char* TraceExtension::kSource = |
110 "native function trace();" | 110 "native function trace();" |
111 "native function js_trace();" | 111 "native function js_trace();" |
112 "native function js_entry_sp();" | 112 "native function js_entry_sp();" |
113 "native function js_entry_sp_level2();"; | 113 "native function js_entry_sp_level2();"; |
114 | 114 |
115 v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate( | 115 v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate( |
116 v8::Isolate* isolate, v8::Handle<String> name) { | 116 v8::Isolate* isolate, v8::Handle<String> name) { |
117 if (name->Equals(String::NewFromUtf8(isolate, "trace"))) { | 117 if (name->Equals(String::NewFromUtf8(isolate, "trace"))) { |
118 return v8::FunctionTemplate::New(TraceExtension::Trace); | 118 return v8::FunctionTemplate::New(isolate, TraceExtension::Trace); |
119 } else if (name->Equals( | 119 } else if (name->Equals( |
120 String::NewFromUtf8(isolate, "js_trace"))) { | 120 String::NewFromUtf8(isolate, "js_trace"))) { |
121 return v8::FunctionTemplate::New(TraceExtension::JSTrace); | 121 return v8::FunctionTemplate::New(isolate, TraceExtension::JSTrace); |
122 } else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp"))) { | 122 } else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp"))) { |
123 return v8::FunctionTemplate::New(TraceExtension::JSEntrySP); | 123 return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySP); |
124 } else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp_level2"))) { | 124 } else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp_level2"))) { |
125 return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2); | 125 return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySPLevel2); |
126 } else { | 126 } else { |
127 CHECK(false); | 127 CHECK(false); |
128 return v8::Handle<v8::FunctionTemplate>(); | 128 return v8::Handle<v8::FunctionTemplate>(); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 | 132 |
133 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { | 133 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { |
134 // 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. |
135 CHECK_EQ(2, args.Length()); // Ignore second argument on 32-bit platform. | 135 CHECK_EQ(2, args.Length()); // Ignore second argument on 32-bit platform. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 #error Host architecture is neither 32-bit nor 64-bit. | 225 #error Host architecture is neither 32-bit nor 64-bit. |
226 #endif | 226 #endif |
227 args.GetReturnValue().Set(args.This()); | 227 args.GetReturnValue().Set(args.This()); |
228 } | 228 } |
229 | 229 |
230 | 230 |
231 // Use the API to create a JSFunction object that calls the above C++ function. | 231 // Use the API to create a JSFunction object that calls the above C++ function. |
232 void CreateFramePointerGrabberConstructor(v8::Local<v8::Context> context, | 232 void CreateFramePointerGrabberConstructor(v8::Local<v8::Context> context, |
233 const char* constructor_name) { | 233 const char* constructor_name) { |
234 Local<v8::FunctionTemplate> constructor_template = | 234 Local<v8::FunctionTemplate> constructor_template = |
235 v8::FunctionTemplate::New(construct_call); | 235 v8::FunctionTemplate::New(context->GetIsolate(), construct_call); |
236 constructor_template->SetClassName(v8_str("FPGrabber")); | 236 constructor_template->SetClassName(v8_str("FPGrabber")); |
237 Local<Function> fun = constructor_template->GetFunction(); | 237 Local<Function> fun = constructor_template->GetFunction(); |
238 context->Global()->Set(v8_str(constructor_name), fun); | 238 context->Global()->Set(v8_str(constructor_name), fun); |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 // Creates a global function named 'func_name' that calls the tracing | 242 // Creates a global function named 'func_name' that calls the tracing |
243 // function 'trace_func_name' with an actual EBP register value, | 243 // function 'trace_func_name' with an actual EBP register value, |
244 // encoded as one or two Smis. | 244 // encoded as one or two Smis. |
245 static void CreateTraceCallerFunction(v8::Local<v8::Context> context, | 245 static void CreateTraceCallerFunction(v8::Local<v8::Context> context, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION); | 404 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION); |
405 v8::Context::Scope context_scope(context); | 405 v8::Context::Scope context_scope(context); |
406 CHECK_EQ(0, GetJsEntrySp()); | 406 CHECK_EQ(0, GetJsEntrySp()); |
407 CompileRun("a = 1; b = a + 1;"); | 407 CompileRun("a = 1; b = a + 1;"); |
408 CHECK_EQ(0, GetJsEntrySp()); | 408 CHECK_EQ(0, GetJsEntrySp()); |
409 CompileRun("js_entry_sp();"); | 409 CompileRun("js_entry_sp();"); |
410 CHECK_EQ(0, GetJsEntrySp()); | 410 CHECK_EQ(0, GetJsEntrySp()); |
411 CompileRun("js_entry_sp_level2();"); | 411 CompileRun("js_entry_sp_level2();"); |
412 CHECK_EQ(0, GetJsEntrySp()); | 412 CHECK_EQ(0, GetJsEntrySp()); |
413 } | 413 } |
OLD | NEW |