Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: test/cctest/test-log-stack-tracer.cc

Issue 12716010: Added a version of the v8::HandleScope constructor with an Isolate and use that consistently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed rest Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 166
167 v8::Handle<v8::Value> TraceExtension::JSEntrySP(const v8::Arguments& args) { 167 v8::Handle<v8::Value> TraceExtension::JSEntrySP(const v8::Arguments& args) {
168 CHECK_NE(0, GetJsEntrySp()); 168 CHECK_NE(0, GetJsEntrySp());
169 return v8::Undefined(); 169 return v8::Undefined();
170 } 170 }
171 171
172 172
173 v8::Handle<v8::Value> TraceExtension::JSEntrySPLevel2( 173 v8::Handle<v8::Value> TraceExtension::JSEntrySPLevel2(
174 const v8::Arguments& args) { 174 const v8::Arguments& args) {
175 v8::HandleScope scope; 175 v8::HandleScope scope(args.GetIsolate());
176 const Address js_entry_sp = GetJsEntrySp(); 176 const Address js_entry_sp = GetJsEntrySp();
177 CHECK_NE(0, js_entry_sp); 177 CHECK_NE(0, js_entry_sp);
178 CompileRun("js_entry_sp();"); 178 CompileRun("js_entry_sp();");
179 CHECK_EQ(js_entry_sp, GetJsEntrySp()); 179 CHECK_EQ(js_entry_sp, GetJsEntrySp());
180 return v8::Undefined(); 180 return v8::Undefined();
181 } 181 }
182 182
183 183
184 static TraceExtension kTraceExtension; 184 static TraceExtension kTraceExtension;
185 v8::DeclareExtension kTraceExtensionDeclaration(&kTraceExtension); 185 v8::DeclareExtension kTraceExtensionDeclaration(&kTraceExtension);
186 186
187 187
188 static void InitializeVM() { 188 static void InitializeVM() {
189 if (env.IsEmpty()) { 189 if (env.IsEmpty()) {
190 v8::HandleScope scope;
191 const char* extensions[] = { "v8/trace" }; 190 const char* extensions[] = { "v8/trace" };
192 v8::ExtensionConfiguration config(1, extensions); 191 v8::ExtensionConfiguration config(1, extensions);
193 env = v8::Context::New(&config); 192 env = v8::Context::New(&config);
194 } 193 }
195 v8::HandleScope scope;
196 env->Enter(); 194 env->Enter();
197 } 195 }
198 196
199 197
200 static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) { 198 static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) {
201 i::Code* code = function->code(); 199 i::Code* code = function->code();
202 return code->contains(addr); 200 return code->contains(addr);
203 } 201 }
204 202
205 static bool IsAddressWithinFuncCode(const char* func_name, Address addr) { 203 static bool IsAddressWithinFuncCode(const char* func_name, Address addr) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // StackTracer uses Isolate::c_entry_fp as a starting point for stack 274 // StackTracer uses Isolate::c_entry_fp as a starting point for stack
277 // walking. 275 // walking.
278 TEST(CFromJSStackTrace) { 276 TEST(CFromJSStackTrace) {
279 // BUG(1303) Inlining of JSFuncDoTrace() in JSTrace below breaks this test. 277 // BUG(1303) Inlining of JSFuncDoTrace() in JSTrace below breaks this test.
280 i::FLAG_use_inlining = false; 278 i::FLAG_use_inlining = false;
281 279
282 TickSample sample; 280 TickSample sample;
283 InitTraceEnv(&sample); 281 InitTraceEnv(&sample);
284 282
285 InitializeVM(); 283 InitializeVM();
286 v8::HandleScope scope; 284 v8::HandleScope scope(env->GetIsolate());
287 // Create global function JSFuncDoTrace which calls 285 // Create global function JSFuncDoTrace which calls
288 // extension function trace() with the current frame pointer value. 286 // extension function trace() with the current frame pointer value.
289 CreateTraceCallerFunction("JSFuncDoTrace", "trace"); 287 CreateTraceCallerFunction("JSFuncDoTrace", "trace");
290 Local<Value> result = CompileRun( 288 Local<Value> result = CompileRun(
291 "function JSTrace() {" 289 "function JSTrace() {"
292 " JSFuncDoTrace();" 290 " JSFuncDoTrace();"
293 "};\n" 291 "};\n"
294 "JSTrace();\n" 292 "JSTrace();\n"
295 "true;"); 293 "true;");
296 CHECK(!result.IsEmpty()); 294 CHECK(!result.IsEmpty());
(...skipping 24 matching lines...) Expand all
321 // pointer value as a starting point for stack walking. 319 // pointer value as a starting point for stack walking.
322 TEST(PureJSStackTrace) { 320 TEST(PureJSStackTrace) {
323 // This test does not pass with inlining enabled since inlined functions 321 // This test does not pass with inlining enabled since inlined functions
324 // don't appear in the stack trace. 322 // don't appear in the stack trace.
325 i::FLAG_use_inlining = false; 323 i::FLAG_use_inlining = false;
326 324
327 TickSample sample; 325 TickSample sample;
328 InitTraceEnv(&sample); 326 InitTraceEnv(&sample);
329 327
330 InitializeVM(); 328 InitializeVM();
331 v8::HandleScope scope; 329 v8::HandleScope scope(env->GetIsolate());
332 // Create global function JSFuncDoTrace which calls 330 // Create global function JSFuncDoTrace which calls
333 // extension function js_trace() with the current frame pointer value. 331 // extension function js_trace() with the current frame pointer value.
334 CreateTraceCallerFunction("JSFuncDoTrace", "js_trace"); 332 CreateTraceCallerFunction("JSFuncDoTrace", "js_trace");
335 Local<Value> result = CompileRun( 333 Local<Value> result = CompileRun(
336 "function JSTrace() {" 334 "function JSTrace() {"
337 " JSFuncDoTrace();" 335 " JSFuncDoTrace();"
338 "};\n" 336 "};\n"
339 "function OuterJSTrace() {" 337 "function OuterJSTrace() {"
340 " JSTrace();" 338 " JSTrace();"
341 "};\n" 339 "};\n"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 TickSample sample; 393 TickSample sample;
396 InitTraceEnv(&sample); 394 InitTraceEnv(&sample);
397 InitializeVM(); 395 InitializeVM();
398 // Check that sampler doesn't crash 396 // Check that sampler doesn't crash
399 CHECK_EQ(10, CFunc(10)); 397 CHECK_EQ(10, CFunc(10));
400 } 398 }
401 399
402 400
403 TEST(JsEntrySp) { 401 TEST(JsEntrySp) {
404 InitializeVM(); 402 InitializeVM();
405 v8::HandleScope scope; 403 v8::HandleScope scope(env->GetIsolate());
406 CHECK_EQ(0, GetJsEntrySp()); 404 CHECK_EQ(0, GetJsEntrySp());
407 CompileRun("a = 1; b = a + 1;"); 405 CompileRun("a = 1; b = a + 1;");
408 CHECK_EQ(0, GetJsEntrySp()); 406 CHECK_EQ(0, GetJsEntrySp());
409 CompileRun("js_entry_sp();"); 407 CompileRun("js_entry_sp();");
410 CHECK_EQ(0, GetJsEntrySp()); 408 CHECK_EQ(0, GetJsEntrySp());
411 CompileRun("js_entry_sp_level2();"); 409 CompileRun("js_entry_sp_level2();");
412 CHECK_EQ(0, GetJsEntrySp()); 410 CHECK_EQ(0, GetJsEntrySp());
413 } 411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698