| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); | 385 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); |
| 386 // This situation can happen if source was an external string disposed | 386 // This situation can happen if source was an external string disposed |
| 387 // by its owner. | 387 // by its owner. |
| 388 i_source->set_resource(NULL); | 388 i_source->set_resource(NULL); |
| 389 | 389 |
| 390 // Must not crash. | 390 // Must not crash. |
| 391 i::Isolate::Current()->logger()->LogCompiledFunctions(); | 391 i::Isolate::Current()->logger()->LogCompiledFunctions(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 | 394 |
| 395 static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) { | 395 static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 396 return v8::Handle<v8::Value>(); | |
| 397 } | 396 } |
| 398 | 397 |
| 399 TEST(LogCallbacks) { | 398 TEST(LogCallbacks) { |
| 400 ScopedLoggerInitializer initialize_logger(false); | 399 ScopedLoggerInitializer initialize_logger(false); |
| 401 Logger* logger = initialize_logger.logger(); | 400 Logger* logger = initialize_logger.logger(); |
| 402 | 401 |
| 403 v8::Local<v8::FunctionTemplate> obj = | 402 v8::Local<v8::FunctionTemplate> obj = |
| 404 v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), | 403 v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), |
| 405 v8::FunctionTemplate::New()); | 404 v8::FunctionTemplate::New()); |
| 406 obj->SetClassName(v8_str("Obj")); | 405 obj->SetClassName(v8_str("Obj")); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 417 | 416 |
| 418 logger->LogCompiledFunctions(); | 417 logger->LogCompiledFunctions(); |
| 419 | 418 |
| 420 bool exists = false; | 419 bool exists = false; |
| 421 i::Vector<const char> log( | 420 i::Vector<const char> log( |
| 422 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); | 421 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); |
| 423 CHECK(exists); | 422 CHECK(exists); |
| 424 | 423 |
| 425 i::EmbeddedVector<char, 100> ref_data; | 424 i::EmbeddedVector<char, 100> ref_data; |
| 426 i::OS::SNPrintF(ref_data, | 425 i::OS::SNPrintF(ref_data, |
| 427 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"method1\"\0", | 426 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"\0", |
| 428 ObjMethod1); | 427 ObjMethod1); |
| 429 | 428 |
| 430 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); | 429 CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); |
| 431 } | 430 } |
| 432 | 431 |
| 433 | 432 |
| 434 static v8::Handle<v8::Value> Prop1Getter(v8::Local<v8::String> property, | 433 static void Prop1Getter(v8::Local<v8::String> property, |
| 435 const v8::AccessorInfo& info) { | 434 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 436 return v8::Handle<v8::Value>(); | |
| 437 } | 435 } |
| 438 | 436 |
| 439 static void Prop1Setter(v8::Local<v8::String> property, | 437 static void Prop1Setter(v8::Local<v8::String> property, |
| 440 v8::Local<v8::Value> value, | 438 v8::Local<v8::Value> value, |
| 441 const v8::AccessorInfo& info) { | 439 const v8::PropertyCallbackInfo<void>& info) { |
| 442 } | 440 } |
| 443 | 441 |
| 444 static v8::Handle<v8::Value> Prop2Getter(v8::Local<v8::String> property, | 442 static void Prop2Getter(v8::Local<v8::String> property, |
| 445 const v8::AccessorInfo& info) { | 443 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 446 return v8::Handle<v8::Value>(); | |
| 447 } | 444 } |
| 448 | 445 |
| 449 TEST(LogAccessorCallbacks) { | 446 TEST(LogAccessorCallbacks) { |
| 450 ScopedLoggerInitializer initialize_logger(false); | 447 ScopedLoggerInitializer initialize_logger(false); |
| 451 Logger* logger = initialize_logger.logger(); | 448 Logger* logger = initialize_logger.logger(); |
| 452 | 449 |
| 453 v8::Local<v8::FunctionTemplate> obj = | 450 v8::Local<v8::FunctionTemplate> obj = |
| 454 v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), | 451 v8::Local<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), |
| 455 v8::FunctionTemplate::New()); | 452 v8::FunctionTemplate::New()); |
| 456 obj->SetClassName(v8_str("Obj")); | 453 obj->SetClassName(v8_str("Obj")); |
| 457 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate(); | 454 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate(); |
| 458 inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter); | 455 inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter); |
| 459 inst->SetAccessor(v8_str("prop2"), Prop2Getter); | 456 inst->SetAccessor(v8_str("prop2"), Prop2Getter); |
| 460 | 457 |
| 461 logger->LogAccessorCallbacks(); | 458 logger->LogAccessorCallbacks(); |
| 462 | 459 |
| 463 bool exists = false; | 460 bool exists = false; |
| 464 i::Vector<const char> log( | 461 i::Vector<const char> log( |
| 465 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); | 462 i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); |
| 466 CHECK(exists); | 463 CHECK(exists); |
| 467 | 464 |
| 468 EmbeddedVector<char, 100> prop1_getter_record; | 465 EmbeddedVector<char, 100> prop1_getter_record; |
| 469 i::OS::SNPrintF(prop1_getter_record, | 466 i::OS::SNPrintF(prop1_getter_record, |
| 470 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"get prop1\"", | 467 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"", |
| 471 Prop1Getter); | 468 Prop1Getter); |
| 472 CHECK_NE(NULL, | 469 CHECK_NE(NULL, |
| 473 StrNStr(log.start(), prop1_getter_record.start(), log.length())); | 470 StrNStr(log.start(), prop1_getter_record.start(), log.length())); |
| 474 | 471 |
| 475 EmbeddedVector<char, 100> prop1_setter_record; | 472 EmbeddedVector<char, 100> prop1_setter_record; |
| 476 i::OS::SNPrintF(prop1_setter_record, | 473 i::OS::SNPrintF(prop1_setter_record, |
| 477 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"set prop1\"", | 474 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"", |
| 478 Prop1Setter); | 475 Prop1Setter); |
| 479 CHECK_NE(NULL, | 476 CHECK_NE(NULL, |
| 480 StrNStr(log.start(), prop1_setter_record.start(), log.length())); | 477 StrNStr(log.start(), prop1_setter_record.start(), log.length())); |
| 481 | 478 |
| 482 EmbeddedVector<char, 100> prop2_getter_record; | 479 EmbeddedVector<char, 100> prop2_getter_record; |
| 483 i::OS::SNPrintF(prop2_getter_record, | 480 i::OS::SNPrintF(prop2_getter_record, |
| 484 "code-creation,Callback,-3,0x%" V8PRIxPTR ",1,\"get prop2\"", | 481 "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"", |
| 485 Prop2Getter); | 482 Prop2Getter); |
| 486 CHECK_NE(NULL, | 483 CHECK_NE(NULL, |
| 487 StrNStr(log.start(), prop2_getter_record.start(), log.length())); | 484 StrNStr(log.start(), prop2_getter_record.start(), log.length())); |
| 488 } | 485 } |
| 489 | 486 |
| 490 | 487 |
| 491 TEST(IsLoggingPreserved) { | 488 TEST(IsLoggingPreserved) { |
| 492 ScopedLoggerInitializer initialize_logger(false); | 489 ScopedLoggerInitializer initialize_logger(false); |
| 493 Logger* logger = initialize_logger.logger(); | 490 Logger* logger = initialize_logger.logger(); |
| 494 | 491 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 v8::Local<v8::String> s = result->ToString(); | 558 v8::Local<v8::String> s = result->ToString(); |
| 562 i::ScopedVector<char> data(s->Utf8Length() + 1); | 559 i::ScopedVector<char> data(s->Utf8Length() + 1); |
| 563 CHECK_NE(NULL, data.start()); | 560 CHECK_NE(NULL, data.start()); |
| 564 s->WriteUtf8(data.start()); | 561 s->WriteUtf8(data.start()); |
| 565 printf("%s\n", data.start()); | 562 printf("%s\n", data.start()); |
| 566 // Make sure that our output is written prior crash due to CHECK failure. | 563 // Make sure that our output is written prior crash due to CHECK failure. |
| 567 fflush(stdout); | 564 fflush(stdout); |
| 568 CHECK(false); | 565 CHECK(false); |
| 569 } | 566 } |
| 570 } | 567 } |
| OLD | NEW |