Revision f230a1cf deps/v8/test/cctest/test-log-stack-tracer.cc

View differences:

deps/v8/test/cctest/test-log-stack-tracer.cc
72 72
  // sp is only used to define stack high bound
73 73
  regs.sp =
74 74
      reinterpret_cast<Address>(trace_env.sample) - 10240;
75
  trace_env.sample->Init(Isolate::Current(), regs);
75
  trace_env.sample->Init(CcTest::i_isolate(), regs);
76 76
}
77 77

  
78 78

  
......
80 80
// pure JS code is being executed
81 81
static void DoTraceHideCEntryFPAddress(Address fp) {
82 82
  v8::internal::Address saved_c_frame_fp =
83
      *(Isolate::Current()->c_entry_fp_address());
83
      *(CcTest::i_isolate()->c_entry_fp_address());
84 84
  CHECK(saved_c_frame_fp);
85
  *(Isolate::Current()->c_entry_fp_address()) = 0;
85
  *(CcTest::i_isolate()->c_entry_fp_address()) = 0;
86 86
  DoTrace(fp);
87
  *(Isolate::Current()->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

  
......
156 156

  
157 157

  
158 158
static Address GetJsEntrySp() {
159
  CHECK_NE(NULL, i::Isolate::Current()->thread_local_top());
160
  return i::Isolate::Current()->js_entry_sp();
159
  CHECK_NE(NULL, CcTest::i_isolate()->thread_local_top());
160
  return CcTest::i_isolate()->js_entry_sp();
161 161
}
162 162

  
163 163

  
......
187 187
}
188 188

  
189 189

  
190
static bool IsAddressWithinFuncCode(const char* func_name, Address addr) {
191
  v8::Local<v8::Value> func = CcTest::env()->Global()->Get(v8_str(func_name));
190
static bool IsAddressWithinFuncCode(v8::Local<v8::Context> context,
191
                                    const char* func_name,
192
                                    Address addr) {
193
  v8::Local<v8::Value> func = context->Global()->Get(v8_str(func_name));
192 194
  CHECK(func->IsFunction());
193 195
  JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func));
194 196
  return IsAddressWithinFuncCode(js_func, addr);
......
225 227

  
226 228

  
227 229
// Use the API to create a JSFunction object that calls the above C++ function.
228
void CreateFramePointerGrabberConstructor(const char* constructor_name) {
230
void CreateFramePointerGrabberConstructor(v8::Local<v8::Context> context,
231
                                          const char* constructor_name) {
229 232
    Local<v8::FunctionTemplate> constructor_template =
230 233
        v8::FunctionTemplate::New(construct_call);
231 234
    constructor_template->SetClassName(v8_str("FPGrabber"));
232 235
    Local<Function> fun = constructor_template->GetFunction();
233
    CcTest::env()->Global()->Set(v8_str(constructor_name), fun);
236
    context->Global()->Set(v8_str(constructor_name), fun);
234 237
}
235 238

  
236 239

  
237 240
// Creates a global function named 'func_name' that calls the tracing
238 241
// function 'trace_func_name' with an actual EBP register value,
239 242
// encoded as one or two Smis.
240
static void CreateTraceCallerFunction(const char* func_name,
243
static void CreateTraceCallerFunction(v8::Local<v8::Context> context,
244
                                      const char* func_name,
241 245
                                      const char* trace_func_name) {
242 246
  i::EmbeddedVector<char, 256> trace_call_buf;
243 247
  i::OS::SNPrintF(trace_call_buf,
......
249 253

  
250 254
  // Create the FPGrabber function, which grabs the caller's frame pointer
251 255
  // when called as a constructor.
252
  CreateFramePointerGrabberConstructor("FPGrabber");
256
  CreateFramePointerGrabberConstructor(context, "FPGrabber");
253 257

  
254 258
  // Compile the script.
255 259
  CompileRun(trace_call_buf.start());
......
267 271
  TickSample sample;
268 272
  InitTraceEnv(&sample);
269 273

  
270
  CcTest::InitializeVM(TRACE_EXTENSION);
271 274
  v8::HandleScope scope(CcTest::isolate());
275
  v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
276
  v8::Context::Scope context_scope(context);
277

  
272 278
  // Create global function JSFuncDoTrace which calls
273 279
  // extension function trace() with the current frame pointer value.
274
  CreateTraceCallerFunction("JSFuncDoTrace", "trace");
280
  CreateTraceCallerFunction(context, "JSFuncDoTrace", "trace");
275 281
  Local<Value> result = CompileRun(
276 282
      "function JSTrace() {"
277 283
      "         JSFuncDoTrace();"
......
294 300
  int base = 0;
295 301
  CHECK_GT(sample.frames_count, base + 1);
296 302

  
297
  CHECK(IsAddressWithinFuncCode("JSFuncDoTrace", sample.stack[base + 0]));
298
  CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 1]));
303
  CHECK(IsAddressWithinFuncCode(
304
      context, "JSFuncDoTrace", sample.stack[base + 0]));
305
  CHECK(IsAddressWithinFuncCode(context, "JSTrace", sample.stack[base + 1]));
299 306
}
300 307

  
301 308

  
......
312 319
  TickSample sample;
313 320
  InitTraceEnv(&sample);
314 321

  
315
  CcTest::InitializeVM(TRACE_EXTENSION);
316 322
  v8::HandleScope scope(CcTest::isolate());
323
  v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
324
  v8::Context::Scope context_scope(context);
325

  
317 326
  // Create global function JSFuncDoTrace which calls
318 327
  // extension function js_trace() with the current frame pointer value.
319
  CreateTraceCallerFunction("JSFuncDoTrace", "js_trace");
328
  CreateTraceCallerFunction(context, "JSFuncDoTrace", "js_trace");
320 329
  Local<Value> result = CompileRun(
321 330
      "function JSTrace() {"
322 331
      "         JSFuncDoTrace();"
......
343 352
  // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace"
344 353
  int base = 0;
345 354
  CHECK_GT(sample.frames_count, base + 1);
346
  CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 0]));
347
  CHECK(IsAddressWithinFuncCode("OuterJSTrace", sample.stack[base + 1]));
355
  CHECK(IsAddressWithinFuncCode(context, "JSTrace", sample.stack[base + 0]));
356
  CHECK(IsAddressWithinFuncCode(
357
      context, "OuterJSTrace", sample.stack[base + 1]));
348 358
}
349 359

  
350 360

  
......
379 389
TEST(PureCStackTrace) {
380 390
  TickSample sample;
381 391
  InitTraceEnv(&sample);
382
  CcTest::InitializeVM(TRACE_EXTENSION);
392
  v8::HandleScope scope(CcTest::isolate());
393
  v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
394
  v8::Context::Scope context_scope(context);
383 395
  // Check that sampler doesn't crash
384 396
  CHECK_EQ(10, CFunc(10));
385 397
}
386 398

  
387 399

  
388 400
TEST(JsEntrySp) {
389
  CcTest::InitializeVM(TRACE_EXTENSION);
390 401
  v8::HandleScope scope(CcTest::isolate());
402
  v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
403
  v8::Context::Scope context_scope(context);
391 404
  CHECK_EQ(0, GetJsEntrySp());
392 405
  CompileRun("a = 1; b = a + 1;");
393 406
  CHECK_EQ(0, GetJsEntrySp());

Also available in: Unified diff