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

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

Issue 12033011: Add Isolate parameter to Persistent class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added explicit Created 7 years, 10 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
« no previous file with comments | « test/cctest/test-lockers.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests of logging functions from log.h 3 // Tests of logging functions from log.h
4 4
5 #ifdef __linux__ 5 #ifdef __linux__
6 #include <math.h> 6 #include <math.h>
7 #include <pthread.h> 7 #include <pthread.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #endif // __linux__ 10 #endif // __linux__
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
364 364
365 static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) { 365 static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) {
366 return v8::Handle<v8::Value>(); 366 return v8::Handle<v8::Value>();
367 } 367 }
368 368
369 TEST(LogCallbacks) { 369 TEST(LogCallbacks) {
370 ScopedLoggerInitializer initialize_logger(false); 370 ScopedLoggerInitializer initialize_logger(false);
371 371
372 v8::Persistent<v8::FunctionTemplate> obj = 372 v8::Persistent<v8::FunctionTemplate> obj =
373 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New()); 373 v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
374 v8::FunctionTemplate::New());
374 obj->SetClassName(v8_str("Obj")); 375 obj->SetClassName(v8_str("Obj"));
375 v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate(); 376 v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
376 v8::Local<v8::Signature> signature = v8::Signature::New(obj); 377 v8::Local<v8::Signature> signature = v8::Signature::New(obj);
377 proto->Set(v8_str("method1"), 378 proto->Set(v8_str("method1"),
378 v8::FunctionTemplate::New(ObjMethod1, 379 v8::FunctionTemplate::New(ObjMethod1,
379 v8::Handle<v8::Value>(), 380 v8::Handle<v8::Value>(),
380 signature), 381 signature),
381 static_cast<v8::PropertyAttribute>(v8::DontDelete)); 382 static_cast<v8::PropertyAttribute>(v8::DontDelete));
382 383
383 initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction()); 384 initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction());
384 CompileRun("Obj.prototype.method1.toString();"); 385 CompileRun("Obj.prototype.method1.toString();");
385 386
386 LOGGER->LogCompiledFunctions(); 387 LOGGER->LogCompiledFunctions();
387 388
388 bool exists = false; 389 bool exists = false;
389 i::Vector<const char> log( 390 i::Vector<const char> log(
390 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); 391 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
391 CHECK(exists); 392 CHECK(exists);
392 393
393 i::EmbeddedVector<char, 100> ref_data; 394 i::EmbeddedVector<char, 100> ref_data;
394 i::OS::SNPrintF(ref_data, 395 i::OS::SNPrintF(ref_data,
395 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"method1\"\0", 396 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"method1\"\0",
396 ObjMethod1); 397 ObjMethod1);
397 398
398 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); 399 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length()));
399 400
400 obj.Dispose(); 401 obj.Dispose(v8::Isolate::GetCurrent());
401 } 402 }
402 403
403 404
404 static v8::Handle<v8::Value> Prop1Getter(v8::Local<v8::String> property, 405 static v8::Handle<v8::Value> Prop1Getter(v8::Local<v8::String> property,
405 const v8::AccessorInfo& info) { 406 const v8::AccessorInfo& info) {
406 return v8::Handle<v8::Value>(); 407 return v8::Handle<v8::Value>();
407 } 408 }
408 409
409 static void Prop1Setter(v8::Local<v8::String> property, 410 static void Prop1Setter(v8::Local<v8::String> property,
410 v8::Local<v8::Value> value, 411 v8::Local<v8::Value> value,
411 const v8::AccessorInfo& info) { 412 const v8::AccessorInfo& info) {
412 } 413 }
413 414
414 static v8::Handle<v8::Value> Prop2Getter(v8::Local<v8::String> property, 415 static v8::Handle<v8::Value> Prop2Getter(v8::Local<v8::String> property,
415 const v8::AccessorInfo& info) { 416 const v8::AccessorInfo& info) {
416 return v8::Handle<v8::Value>(); 417 return v8::Handle<v8::Value>();
417 } 418 }
418 419
419 TEST(LogAccessorCallbacks) { 420 TEST(LogAccessorCallbacks) {
420 ScopedLoggerInitializer initialize_logger(false); 421 ScopedLoggerInitializer initialize_logger(false);
421 422
422 v8::Persistent<v8::FunctionTemplate> obj = 423 v8::Persistent<v8::FunctionTemplate> obj =
423 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New()); 424 v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
425 v8::FunctionTemplate::New());
424 obj->SetClassName(v8_str("Obj")); 426 obj->SetClassName(v8_str("Obj"));
425 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate(); 427 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
426 inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter); 428 inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
427 inst->SetAccessor(v8_str("prop2"), Prop2Getter); 429 inst->SetAccessor(v8_str("prop2"), Prop2Getter);
428 430
429 LOGGER->LogAccessorCallbacks(); 431 LOGGER->LogAccessorCallbacks();
430 432
431 bool exists = false; 433 bool exists = false;
432 i::Vector<const char> log( 434 i::Vector<const char> log(
433 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); 435 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
(...skipping 13 matching lines...) Expand all
447 CHECK_NE(NULL, 449 CHECK_NE(NULL,
448 StrNStr(log.start(), prop1_setter_record.start(), log.length())); 450 StrNStr(log.start(), prop1_setter_record.start(), log.length()));
449 451
450 EmbeddedVector<char, 100> prop2_getter_record; 452 EmbeddedVector<char, 100> prop2_getter_record;
451 i::OS::SNPrintF(prop2_getter_record, 453 i::OS::SNPrintF(prop2_getter_record,
452 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"get prop2\"", 454 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"get prop2\"",
453 Prop2Getter); 455 Prop2Getter);
454 CHECK_NE(NULL, 456 CHECK_NE(NULL,
455 StrNStr(log.start(), prop2_getter_record.start(), log.length())); 457 StrNStr(log.start(), prop2_getter_record.start(), log.length()));
456 458
457 obj.Dispose(); 459 obj.Dispose(v8::Isolate::GetCurrent());
458 } 460 }
459 461
460 462
461 TEST(IsLoggingPreserved) { 463 TEST(IsLoggingPreserved) {
462 ScopedLoggerInitializer initialize_logger(false); 464 ScopedLoggerInitializer initialize_logger(false);
463 465
464 CHECK(LOGGER->is_logging()); 466 CHECK(LOGGER->is_logging());
465 LOGGER->ResumeProfiler(); 467 LOGGER->ResumeProfiler();
466 CHECK(LOGGER->is_logging()); 468 CHECK(LOGGER->is_logging());
467 LOGGER->PauseProfiler(); 469 LOGGER->PauseProfiler();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 v8::Local<v8::String> s = result->ToString(); 531 v8::Local<v8::String> s = result->ToString();
530 i::ScopedVector<char> data(s->Length() + 1); 532 i::ScopedVector<char> data(s->Length() + 1);
531 CHECK_NE(NULL, data.start()); 533 CHECK_NE(NULL, data.start());
532 s->WriteAscii(data.start()); 534 s->WriteAscii(data.start());
533 printf("%s\n", data.start()); 535 printf("%s\n", data.start());
534 // Make sure that our output is written prior crash due to CHECK failure. 536 // Make sure that our output is written prior crash due to CHECK failure.
535 fflush(stdout); 537 fflush(stdout);
536 CHECK(false); 538 CHECK(false);
537 } 539 }
538 } 540 }
OLDNEW
« no previous file with comments | « test/cctest/test-lockers.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698