OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 LocalContext env; | 397 LocalContext env; |
398 TestResource* resource = new TestResource(two_byte_source, &dispose_count); | 398 TestResource* resource = new TestResource(two_byte_source, &dispose_count); |
399 Local<String> source = String::NewExternal(resource); | 399 Local<String> source = String::NewExternal(resource); |
400 Local<Script> script = Script::Compile(source); | 400 Local<Script> script = Script::Compile(source); |
401 Local<Value> value = script->Run(); | 401 Local<Value> value = script->Run(); |
402 CHECK(value->IsNumber()); | 402 CHECK(value->IsNumber()); |
403 CHECK_EQ(7, value->Int32Value()); | 403 CHECK_EQ(7, value->Int32Value()); |
404 CHECK(source->IsExternal()); | 404 CHECK(source->IsExternal()); |
405 CHECK_EQ(resource, | 405 CHECK_EQ(resource, |
406 static_cast<TestResource*>(source->GetExternalStringResource())); | 406 static_cast<TestResource*>(source->GetExternalStringResource())); |
407 String::Encoding encoding = String::UNKNOWN_ENCODING; | |
408 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | |
409 source->GetExternalStringResourceBase(&encoding)); | |
410 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); | |
411 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 407 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
412 CHECK_EQ(0, dispose_count); | 408 CHECK_EQ(0, dispose_count); |
413 } | 409 } |
414 v8::internal::Isolate::Current()->compilation_cache()->Clear(); | 410 v8::internal::Isolate::Current()->compilation_cache()->Clear(); |
415 HEAP->CollectAllAvailableGarbage(); | 411 HEAP->CollectAllAvailableGarbage(); |
416 CHECK_EQ(1, dispose_count); | 412 CHECK_EQ(1, dispose_count); |
417 } | 413 } |
418 | 414 |
419 | 415 |
420 THREADED_TEST(ScriptUsingAsciiStringResource) { | 416 THREADED_TEST(ScriptUsingAsciiStringResource) { |
421 int dispose_count = 0; | 417 int dispose_count = 0; |
422 const char* c_source = "1 + 2 * 3"; | 418 const char* c_source = "1 + 2 * 3"; |
423 { | 419 { |
424 v8::HandleScope scope; | 420 v8::HandleScope scope; |
425 LocalContext env; | 421 LocalContext env; |
426 TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source), | 422 Local<String> source = |
427 &dispose_count); | 423 String::NewExternal(new TestAsciiResource(i::StrDup(c_source), |
428 Local<String> source = String::NewExternal(resource); | 424 &dispose_count)); |
429 CHECK(source->IsExternalAscii()); | |
430 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | |
431 source->GetExternalAsciiStringResource()); | |
432 String::Encoding encoding = String::UNKNOWN_ENCODING; | |
433 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | |
434 source->GetExternalStringResourceBase(&encoding)); | |
435 CHECK_EQ(String::ASCII_ENCODING, encoding); | |
436 Local<Script> script = Script::Compile(source); | 425 Local<Script> script = Script::Compile(source); |
437 Local<Value> value = script->Run(); | 426 Local<Value> value = script->Run(); |
438 CHECK(value->IsNumber()); | 427 CHECK(value->IsNumber()); |
439 CHECK_EQ(7, value->Int32Value()); | 428 CHECK_EQ(7, value->Int32Value()); |
440 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 429 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
441 CHECK_EQ(0, dispose_count); | 430 CHECK_EQ(0, dispose_count); |
442 } | 431 } |
443 i::Isolate::Current()->compilation_cache()->Clear(); | 432 i::Isolate::Current()->compilation_cache()->Clear(); |
444 HEAP->CollectAllAvailableGarbage(); | 433 HEAP->CollectAllAvailableGarbage(); |
445 CHECK_EQ(1, dispose_count); | 434 CHECK_EQ(1, dispose_count); |
446 } | 435 } |
447 | 436 |
448 | 437 |
449 THREADED_TEST(ScriptMakingExternalString) { | 438 THREADED_TEST(ScriptMakingExternalString) { |
450 int dispose_count = 0; | 439 int dispose_count = 0; |
451 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); | 440 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); |
452 { | 441 { |
453 v8::HandleScope scope; | 442 v8::HandleScope scope; |
454 LocalContext env; | 443 LocalContext env; |
455 Local<String> source = String::New(two_byte_source); | 444 Local<String> source = String::New(two_byte_source); |
456 // Trigger GCs so that the newly allocated string moves to old gen. | 445 // Trigger GCs so that the newly allocated string moves to old gen. |
457 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 446 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now |
458 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 447 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
459 CHECK_EQ(source->IsExternal(), false); | |
460 CHECK_EQ(source->IsExternalAscii(), false); | |
461 String::Encoding encoding = String::UNKNOWN_ENCODING; | |
462 CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); | |
463 CHECK_EQ(String::ASCII_ENCODING, encoding); | |
464 bool success = source->MakeExternal(new TestResource(two_byte_source, | 448 bool success = source->MakeExternal(new TestResource(two_byte_source, |
465 &dispose_count)); | 449 &dispose_count)); |
466 CHECK(success); | 450 CHECK(success); |
467 Local<Script> script = Script::Compile(source); | 451 Local<Script> script = Script::Compile(source); |
468 Local<Value> value = script->Run(); | 452 Local<Value> value = script->Run(); |
469 CHECK(value->IsNumber()); | 453 CHECK(value->IsNumber()); |
470 CHECK_EQ(7, value->Int32Value()); | 454 CHECK_EQ(7, value->Int32Value()); |
471 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 455 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
472 CHECK_EQ(0, dispose_count); | 456 CHECK_EQ(0, dispose_count); |
473 } | 457 } |
(...skipping 4206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4680 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 4664 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
4681 const char* extension_names[] = { "simpletest" }; | 4665 const char* extension_names[] = { "simpletest" }; |
4682 v8::ExtensionConfiguration extensions(1, extension_names); | 4666 v8::ExtensionConfiguration extensions(1, extension_names); |
4683 v8::Handle<Context> context = Context::New(&extensions); | 4667 v8::Handle<Context> context = Context::New(&extensions); |
4684 Context::Scope lock(context); | 4668 Context::Scope lock(context); |
4685 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 4669 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
4686 CHECK_EQ(result, v8::Integer::New(4)); | 4670 CHECK_EQ(result, v8::Integer::New(4)); |
4687 } | 4671 } |
4688 | 4672 |
4689 | 4673 |
4690 THREADED_TEST(NullExtensions) { | |
4691 v8::HandleScope handle_scope; | |
4692 v8::RegisterExtension(new Extension("nulltest", NULL)); | |
4693 const char* extension_names[] = { "nulltest" }; | |
4694 v8::ExtensionConfiguration extensions(1, extension_names); | |
4695 v8::Handle<Context> context = Context::New(&extensions); | |
4696 Context::Scope lock(context); | |
4697 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); | |
4698 CHECK_EQ(result, v8::Integer::New(4)); | |
4699 } | |
4700 | |
4701 | |
4702 static const char* kEmbeddedExtensionSource = | 4674 static const char* kEmbeddedExtensionSource = |
4703 "function Ret54321(){return 54321;}~~@@$" | 4675 "function Ret54321(){return 54321;}~~@@$" |
4704 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; | 4676 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; |
4705 static const int kEmbeddedExtensionSourceValidLen = 34; | 4677 static const int kEmbeddedExtensionSourceValidLen = 34; |
4706 | 4678 |
4707 | 4679 |
4708 THREADED_TEST(ExtensionMissingSourceLength) { | 4680 THREADED_TEST(ExtensionMissingSourceLength) { |
4709 v8::HandleScope handle_scope; | 4681 v8::HandleScope handle_scope; |
4710 v8::RegisterExtension(new Extension("srclentest_fail", | 4682 v8::RegisterExtension(new Extension("srclentest_fail", |
4711 kEmbeddedExtensionSource)); | 4683 kEmbeddedExtensionSource)); |
(...skipping 9320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14032 ExternalArrayInfoTestHelper(v8::kExternalShortArray); | 14004 ExternalArrayInfoTestHelper(v8::kExternalShortArray); |
14033 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); | 14005 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); |
14034 ExternalArrayInfoTestHelper(v8::kExternalIntArray); | 14006 ExternalArrayInfoTestHelper(v8::kExternalIntArray); |
14035 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); | 14007 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); |
14036 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); | 14008 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); |
14037 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); | 14009 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray); |
14038 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); | 14010 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); |
14039 } | 14011 } |
14040 | 14012 |
14041 | 14013 |
14042 void ExternalArrayLimitTestHelper(v8::ExternalArrayType array_type, int size) { | |
14043 v8::Handle<v8::Object> obj = v8::Object::New(); | |
14044 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | |
14045 last_location = last_message = NULL; | |
14046 obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size); | |
14047 CHECK(!obj->HasIndexedPropertiesInExternalArrayData()); | |
14048 CHECK_NE(NULL, last_location); | |
14049 CHECK_NE(NULL, last_message); | |
14050 } | |
14051 | |
14052 | |
14053 TEST(ExternalArrayLimits) { | |
14054 v8::HandleScope scope; | |
14055 LocalContext context; | |
14056 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0x40000000); | |
14057 ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0xffffffff); | |
14058 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0x40000000); | |
14059 ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0xffffffff); | |
14060 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0x40000000); | |
14061 ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0xffffffff); | |
14062 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0x40000000); | |
14063 ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0xffffffff); | |
14064 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0x40000000); | |
14065 ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0xffffffff); | |
14066 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0x40000000); | |
14067 ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0xffffffff); | |
14068 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0x40000000); | |
14069 ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0xffffffff); | |
14070 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0x40000000); | |
14071 ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0xffffffff); | |
14072 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0x40000000); | |
14073 ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0xffffffff); | |
14074 } | |
14075 | |
14076 | |
14077 THREADED_TEST(ScriptContextDependence) { | 14014 THREADED_TEST(ScriptContextDependence) { |
14078 v8::HandleScope scope; | 14015 v8::HandleScope scope; |
14079 LocalContext c1; | 14016 LocalContext c1; |
14080 const char *source = "foo"; | 14017 const char *source = "foo"; |
14081 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); | 14018 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); |
14082 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); | 14019 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); |
14083 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100)); | 14020 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100)); |
14084 CHECK_EQ(dep->Run()->Int32Value(), 100); | 14021 CHECK_EQ(dep->Run()->Int32Value(), 100); |
14085 CHECK_EQ(indep->Run()->Int32Value(), 100); | 14022 CHECK_EQ(indep->Run()->Int32Value(), 100); |
14086 LocalContext c2; | 14023 LocalContext c2; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14445 "\n" | 14382 "\n" |
14446 " bar();\n" | 14383 " bar();\n" |
14447 "}\n" | 14384 "}\n" |
14448 "foo();\n" | 14385 "foo();\n" |
14449 "}\n" | 14386 "}\n" |
14450 "eval('(' + outer +')()//@ sourceURL=eval_url');"; | 14387 "eval('(' + outer +')()//@ sourceURL=eval_url');"; |
14451 CHECK(CompileRun(source)->IsUndefined()); | 14388 CHECK(CompileRun(source)->IsUndefined()); |
14452 } | 14389 } |
14453 | 14390 |
14454 | 14391 |
14455 v8::Handle<Value> AnalyzeStackOfInlineScriptWithSourceURL( | |
14456 const v8::Arguments& args) { | |
14457 v8::HandleScope scope; | |
14458 v8::Handle<v8::StackTrace> stackTrace = | |
14459 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | |
14460 CHECK_EQ(4, stackTrace->GetFrameCount()); | |
14461 v8::Handle<v8::String> url = v8_str("url"); | |
14462 for (int i = 0; i < 3; i++) { | |
14463 v8::Handle<v8::String> name = | |
14464 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | |
14465 CHECK(!name.IsEmpty()); | |
14466 CHECK_EQ(url, name); | |
14467 } | |
14468 return v8::Undefined(); | |
14469 } | |
14470 | |
14471 | |
14472 TEST(InlineScriptWithSourceURLInStackTrace) { | |
14473 v8::HandleScope scope; | |
14474 Local<ObjectTemplate> templ = ObjectTemplate::New(); | |
14475 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), | |
14476 v8::FunctionTemplate::New( | |
14477 AnalyzeStackOfInlineScriptWithSourceURL)); | |
14478 LocalContext context(0, templ); | |
14479 | |
14480 const char *source = | |
14481 "function outer() {\n" | |
14482 "function bar() {\n" | |
14483 " AnalyzeStackOfInlineScriptWithSourceURL();\n" | |
14484 "}\n" | |
14485 "function foo() {\n" | |
14486 "\n" | |
14487 " bar();\n" | |
14488 "}\n" | |
14489 "foo();\n" | |
14490 "}\n" | |
14491 "outer()\n" | |
14492 "//@ sourceURL=source_url"; | |
14493 CHECK(CompileRunWithOrigin(source, "url", 0, 1)->IsUndefined()); | |
14494 } | |
14495 | |
14496 | |
14497 v8::Handle<Value> AnalyzeStackOfDynamicScriptWithSourceURL( | |
14498 const v8::Arguments& args) { | |
14499 v8::HandleScope scope; | |
14500 v8::Handle<v8::StackTrace> stackTrace = | |
14501 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | |
14502 CHECK_EQ(4, stackTrace->GetFrameCount()); | |
14503 v8::Handle<v8::String> url = v8_str("source_url"); | |
14504 for (int i = 0; i < 3; i++) { | |
14505 v8::Handle<v8::String> name = | |
14506 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | |
14507 CHECK(!name.IsEmpty()); | |
14508 CHECK_EQ(url, name); | |
14509 } | |
14510 return v8::Undefined(); | |
14511 } | |
14512 | |
14513 | |
14514 TEST(DynamicWithSourceURLInStackTrace) { | |
14515 v8::HandleScope scope; | |
14516 Local<ObjectTemplate> templ = ObjectTemplate::New(); | |
14517 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), | |
14518 v8::FunctionTemplate::New( | |
14519 AnalyzeStackOfDynamicScriptWithSourceURL)); | |
14520 LocalContext context(0, templ); | |
14521 | |
14522 const char *source = | |
14523 "function outer() {\n" | |
14524 "function bar() {\n" | |
14525 " AnalyzeStackOfDynamicScriptWithSourceURL();\n" | |
14526 "}\n" | |
14527 "function foo() {\n" | |
14528 "\n" | |
14529 " bar();\n" | |
14530 "}\n" | |
14531 "foo();\n" | |
14532 "}\n" | |
14533 "outer()\n" | |
14534 "//@ sourceURL=source_url"; | |
14535 CHECK(CompileRunWithOrigin(source, "url", 0, 0)->IsUndefined()); | |
14536 } | |
14537 | |
14538 static void CreateGarbageInOldSpace() { | 14392 static void CreateGarbageInOldSpace() { |
14539 v8::HandleScope scope; | 14393 v8::HandleScope scope; |
14540 i::AlwaysAllocateScope always_allocate; | 14394 i::AlwaysAllocateScope always_allocate; |
14541 for (int i = 0; i < 1000; i++) { | 14395 for (int i = 0; i < 1000; i++) { |
14542 FACTORY->NewFixedArray(1000, i::TENURED); | 14396 FACTORY->NewFixedArray(1000, i::TENURED); |
14543 } | 14397 } |
14544 } | 14398 } |
14545 | 14399 |
14546 // Test that idle notification can be handled and eventually returns true. | 14400 // Test that idle notification can be handled and eventually returns true. |
14547 TEST(IdleNotification) { | 14401 TEST(IdleNotification) { |
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16600 CHECK(!context->IsCodeGenerationFromStringsAllowed()); | 16454 CHECK(!context->IsCodeGenerationFromStringsAllowed()); |
16601 CheckCodeGenerationAllowed(); | 16455 CheckCodeGenerationAllowed(); |
16602 | 16456 |
16603 // Set a callback that disallows the code generation. | 16457 // Set a callback that disallows the code generation. |
16604 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); | 16458 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); |
16605 CHECK(!context->IsCodeGenerationFromStringsAllowed()); | 16459 CHECK(!context->IsCodeGenerationFromStringsAllowed()); |
16606 CheckCodeGenerationDisallowed(); | 16460 CheckCodeGenerationDisallowed(); |
16607 } | 16461 } |
16608 | 16462 |
16609 | 16463 |
16610 TEST(SetErrorMessageForCodeGenFromStrings) { | |
16611 v8::HandleScope scope; | |
16612 LocalContext context; | |
16613 TryCatch try_catch; | |
16614 | |
16615 Handle<String> message = v8_str("Message") ; | |
16616 Handle<String> expected_message = v8_str("Uncaught EvalError: Message"); | |
16617 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); | |
16618 context->AllowCodeGenerationFromStrings(false); | |
16619 context->SetErrorMessageForCodeGenerationFromStrings(message); | |
16620 Handle<Value> result = CompileRun("eval('42')"); | |
16621 CHECK(result.IsEmpty()); | |
16622 CHECK(try_catch.HasCaught()); | |
16623 Handle<String> actual_message = try_catch.Message()->Get(); | |
16624 CHECK(expected_message->Equals(actual_message)); | |
16625 } | |
16626 | |
16627 | |
16628 static v8::Handle<Value> NonObjectThis(const v8::Arguments& args) { | 16464 static v8::Handle<Value> NonObjectThis(const v8::Arguments& args) { |
16629 return v8::Undefined(); | 16465 return v8::Undefined(); |
16630 } | 16466 } |
16631 | 16467 |
16632 | 16468 |
16633 THREADED_TEST(CallAPIFunctionOnNonObject) { | 16469 THREADED_TEST(CallAPIFunctionOnNonObject) { |
16634 v8::HandleScope scope; | 16470 v8::HandleScope scope; |
16635 LocalContext context; | 16471 LocalContext context; |
16636 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); | 16472 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); |
16637 Handle<Function> function = templ->GetFunction(); | 16473 Handle<Function> function = templ->GetFunction(); |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17545 | 17381 |
17546 // Compile a try-finally clause where the finally block causes a GC | 17382 // Compile a try-finally clause where the finally block causes a GC |
17547 // while there still is a message pending for external reporting. | 17383 // while there still is a message pending for external reporting. |
17548 TryCatch try_catch; | 17384 TryCatch try_catch; |
17549 try_catch.SetVerbose(true); | 17385 try_catch.SetVerbose(true); |
17550 CompileRun("try { throw new Error(); } finally { gc(); }"); | 17386 CompileRun("try { throw new Error(); } finally { gc(); }"); |
17551 CHECK(try_catch.HasCaught()); | 17387 CHECK(try_catch.HasCaught()); |
17552 } | 17388 } |
17553 | 17389 |
17554 | 17390 |
17555 THREADED_TEST(Regress149912) { | |
17556 v8::HandleScope scope; | |
17557 LocalContext context; | |
17558 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | |
17559 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); | |
17560 context->Global()->Set(v8_str("Bug"), templ->GetFunction()); | |
17561 CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();"); | |
17562 } | |
17563 | |
17564 | |
17565 #ifndef WIN32 | 17391 #ifndef WIN32 |
17566 class ThreadInterruptTest { | 17392 class ThreadInterruptTest { |
17567 public: | 17393 public: |
17568 ThreadInterruptTest() : sem_(NULL), sem_value_(0) { } | 17394 ThreadInterruptTest() : sem_(NULL), sem_value_(0) { } |
17569 ~ThreadInterruptTest() { delete sem_; } | 17395 ~ThreadInterruptTest() { delete sem_; } |
17570 | 17396 |
17571 void RunTest() { | 17397 void RunTest() { |
17572 sem_ = i::OS::CreateSemaphore(0); | 17398 sem_ = i::OS::CreateSemaphore(0); |
17573 | 17399 |
17574 InterruptThread i_thread(this); | 17400 InterruptThread i_thread(this); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17618 | 17444 |
17619 i::Semaphore* sem_; | 17445 i::Semaphore* sem_; |
17620 volatile int sem_value_; | 17446 volatile int sem_value_; |
17621 }; | 17447 }; |
17622 | 17448 |
17623 | 17449 |
17624 THREADED_TEST(SemaphoreInterruption) { | 17450 THREADED_TEST(SemaphoreInterruption) { |
17625 ThreadInterruptTest().RunTest(); | 17451 ThreadInterruptTest().RunTest(); |
17626 } | 17452 } |
17627 #endif // WIN32 | 17453 #endif // WIN32 |
OLD | NEW |