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 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 v8::Local<Value> boxed_boolean = CompileRun("new Boolean(true)"); | 1717 v8::Local<Value> boxed_boolean = CompileRun("new Boolean(true)"); |
1718 CHECK(boxed_boolean->IsBooleanObject()); | 1718 CHECK(boxed_boolean->IsBooleanObject()); |
1719 v8::Local<Value> unboxed_boolean = CompileRun("true"); | 1719 v8::Local<Value> unboxed_boolean = CompileRun("true"); |
1720 CHECK(!unboxed_boolean->IsBooleanObject()); | 1720 CHECK(!unboxed_boolean->IsBooleanObject()); |
1721 v8::Local<Value> boxed_not_boolean = CompileRun("new Number(42)"); | 1721 v8::Local<Value> boxed_not_boolean = CompileRun("new Number(42)"); |
1722 CHECK(!boxed_not_boolean->IsBooleanObject()); | 1722 CHECK(!boxed_not_boolean->IsBooleanObject()); |
1723 v8::Local<v8::BooleanObject> as_boxed = boxed_boolean.As<v8::BooleanObject>(); | 1723 v8::Local<v8::BooleanObject> as_boxed = boxed_boolean.As<v8::BooleanObject>(); |
1724 CHECK(!as_boxed.IsEmpty()); | 1724 CHECK(!as_boxed.IsEmpty()); |
1725 bool the_boolean = as_boxed->ValueOf(); | 1725 bool the_boolean = as_boxed->ValueOf(); |
1726 CHECK_EQ(true, the_boolean); | 1726 CHECK_EQ(true, the_boolean); |
1727 v8::Local<v8::Value> boxed_true = v8::BooleanObject::New(true); | 1727 v8::Local<v8::Value> boxed_true = |
1728 v8::Local<v8::Value> boxed_false = v8::BooleanObject::New(false); | 1728 v8::BooleanObject::New(env->GetIsolate(), true); |
| 1729 v8::Local<v8::Value> boxed_false = |
| 1730 v8::BooleanObject::New(env->GetIsolate(), false); |
1729 CHECK(boxed_true->IsBooleanObject()); | 1731 CHECK(boxed_true->IsBooleanObject()); |
1730 CHECK(boxed_false->IsBooleanObject()); | 1732 CHECK(boxed_false->IsBooleanObject()); |
1731 as_boxed = boxed_true.As<v8::BooleanObject>(); | 1733 as_boxed = boxed_true.As<v8::BooleanObject>(); |
1732 CHECK_EQ(true, as_boxed->ValueOf()); | 1734 CHECK_EQ(true, as_boxed->ValueOf()); |
1733 as_boxed = boxed_false.As<v8::BooleanObject>(); | 1735 as_boxed = boxed_false.As<v8::BooleanObject>(); |
1734 CHECK_EQ(false, as_boxed->ValueOf()); | 1736 CHECK_EQ(false, as_boxed->ValueOf()); |
1735 } | 1737 } |
1736 | 1738 |
1737 | 1739 |
1738 THREADED_TEST(PrimitiveAndWrappedBooleans) { | 1740 THREADED_TEST(PrimitiveAndWrappedBooleans) { |
1739 LocalContext env; | 1741 LocalContext env; |
1740 v8::HandleScope scope(env->GetIsolate()); | 1742 v8::HandleScope scope(env->GetIsolate()); |
1741 | 1743 |
1742 Local<Value> primitive_false = Boolean::New(env->GetIsolate(), false); | 1744 Local<Value> primitive_false = Boolean::New(env->GetIsolate(), false); |
1743 CHECK(primitive_false->IsBoolean()); | 1745 CHECK(primitive_false->IsBoolean()); |
1744 CHECK(!primitive_false->IsBooleanObject()); | 1746 CHECK(!primitive_false->IsBooleanObject()); |
1745 CHECK(!primitive_false->BooleanValue(env.local()).FromJust()); | 1747 CHECK(!primitive_false->BooleanValue(env.local()).FromJust()); |
1746 CHECK(!primitive_false->IsTrue()); | 1748 CHECK(!primitive_false->IsTrue()); |
1747 CHECK(primitive_false->IsFalse()); | 1749 CHECK(primitive_false->IsFalse()); |
1748 | 1750 |
1749 Local<Value> false_value = BooleanObject::New(false); | 1751 Local<Value> false_value = BooleanObject::New(env->GetIsolate(), false); |
1750 CHECK(!false_value->IsBoolean()); | 1752 CHECK(!false_value->IsBoolean()); |
1751 CHECK(false_value->IsBooleanObject()); | 1753 CHECK(false_value->IsBooleanObject()); |
1752 CHECK(false_value->BooleanValue(env.local()).FromJust()); | 1754 CHECK(false_value->BooleanValue(env.local()).FromJust()); |
1753 CHECK(!false_value->IsTrue()); | 1755 CHECK(!false_value->IsTrue()); |
1754 CHECK(!false_value->IsFalse()); | 1756 CHECK(!false_value->IsFalse()); |
1755 | 1757 |
1756 Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>(); | 1758 Local<BooleanObject> false_boolean_object = false_value.As<BooleanObject>(); |
1757 CHECK(!false_boolean_object->IsBoolean()); | 1759 CHECK(!false_boolean_object->IsBoolean()); |
1758 CHECK(false_boolean_object->IsBooleanObject()); | 1760 CHECK(false_boolean_object->IsBooleanObject()); |
1759 CHECK(false_boolean_object->BooleanValue(env.local()).FromJust()); | 1761 CHECK(false_boolean_object->BooleanValue(env.local()).FromJust()); |
1760 CHECK(!false_boolean_object->ValueOf()); | 1762 CHECK(!false_boolean_object->ValueOf()); |
1761 CHECK(!false_boolean_object->IsTrue()); | 1763 CHECK(!false_boolean_object->IsTrue()); |
1762 CHECK(!false_boolean_object->IsFalse()); | 1764 CHECK(!false_boolean_object->IsFalse()); |
1763 | 1765 |
1764 Local<Value> primitive_true = Boolean::New(env->GetIsolate(), true); | 1766 Local<Value> primitive_true = Boolean::New(env->GetIsolate(), true); |
1765 CHECK(primitive_true->IsBoolean()); | 1767 CHECK(primitive_true->IsBoolean()); |
1766 CHECK(!primitive_true->IsBooleanObject()); | 1768 CHECK(!primitive_true->IsBooleanObject()); |
1767 CHECK(primitive_true->BooleanValue(env.local()).FromJust()); | 1769 CHECK(primitive_true->BooleanValue(env.local()).FromJust()); |
1768 CHECK(primitive_true->IsTrue()); | 1770 CHECK(primitive_true->IsTrue()); |
1769 CHECK(!primitive_true->IsFalse()); | 1771 CHECK(!primitive_true->IsFalse()); |
1770 | 1772 |
1771 Local<Value> true_value = BooleanObject::New(true); | 1773 Local<Value> true_value = BooleanObject::New(env->GetIsolate(), true); |
1772 CHECK(!true_value->IsBoolean()); | 1774 CHECK(!true_value->IsBoolean()); |
1773 CHECK(true_value->IsBooleanObject()); | 1775 CHECK(true_value->IsBooleanObject()); |
1774 CHECK(true_value->BooleanValue(env.local()).FromJust()); | 1776 CHECK(true_value->BooleanValue(env.local()).FromJust()); |
1775 CHECK(!true_value->IsTrue()); | 1777 CHECK(!true_value->IsTrue()); |
1776 CHECK(!true_value->IsFalse()); | 1778 CHECK(!true_value->IsFalse()); |
1777 | 1779 |
1778 Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>(); | 1780 Local<BooleanObject> true_boolean_object = true_value.As<BooleanObject>(); |
1779 CHECK(!true_boolean_object->IsBoolean()); | 1781 CHECK(!true_boolean_object->IsBoolean()); |
1780 CHECK(true_boolean_object->IsBooleanObject()); | 1782 CHECK(true_boolean_object->IsBooleanObject()); |
1781 CHECK(true_boolean_object->BooleanValue(env.local()).FromJust()); | 1783 CHECK(true_boolean_object->BooleanValue(env.local()).FromJust()); |
(...skipping 6913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8695 obj->NewInstance(context.local()).ToLocalChecked(); | 8697 obj->NewInstance(context.local()).ToLocalChecked(); |
8696 CHECK(context->Global() | 8698 CHECK(context->Global() |
8697 ->Set(context.local(), v8_str("holder"), holder) | 8699 ->Set(context.local(), v8_str("holder"), holder) |
8698 .FromJust()); | 8700 .FromJust()); |
8699 v8::Local<Value> result = | 8701 v8::Local<Value> result = |
8700 CompileRun("holder.y = 11; holder.y = 12; holder.y"); | 8702 CompileRun("holder.y = 11; holder.y = 12; holder.y"); |
8701 CHECK_EQ(12u, result->Uint32Value(context.local()).FromJust()); | 8703 CHECK_EQ(12u, result->Uint32Value(context.local()).FromJust()); |
8702 } | 8704 } |
8703 | 8705 |
8704 | 8706 |
8705 THREADED_TEST(TypeSwitch) { | |
8706 v8::Isolate* isolate = CcTest::isolate(); | |
8707 v8::HandleScope scope(isolate); | |
8708 v8::Local<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(isolate); | |
8709 v8::Local<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(isolate); | |
8710 v8::Local<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(isolate); | |
8711 v8::Local<v8::FunctionTemplate> templs[3] = {templ1, templ2, templ3}; | |
8712 v8::Local<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); | |
8713 LocalContext context; | |
8714 v8::Local<v8::Object> obj0 = v8::Object::New(isolate); | |
8715 v8::Local<v8::Object> obj1 = templ1->GetFunction(context.local()) | |
8716 .ToLocalChecked() | |
8717 ->NewInstance(context.local()) | |
8718 .ToLocalChecked(); | |
8719 v8::Local<v8::Object> obj2 = templ2->GetFunction(context.local()) | |
8720 .ToLocalChecked() | |
8721 ->NewInstance(context.local()) | |
8722 .ToLocalChecked(); | |
8723 v8::Local<v8::Object> obj3 = templ3->GetFunction(context.local()) | |
8724 .ToLocalChecked() | |
8725 ->NewInstance(context.local()) | |
8726 .ToLocalChecked(); | |
8727 for (int i = 0; i < 10; i++) { | |
8728 CHECK_EQ(0, type_switch->match(obj0)); | |
8729 CHECK_EQ(1, type_switch->match(obj1)); | |
8730 CHECK_EQ(2, type_switch->match(obj2)); | |
8731 CHECK_EQ(3, type_switch->match(obj3)); | |
8732 CHECK_EQ(3, type_switch->match(obj3)); | |
8733 CHECK_EQ(2, type_switch->match(obj2)); | |
8734 CHECK_EQ(1, type_switch->match(obj1)); | |
8735 CHECK_EQ(0, type_switch->match(obj0)); | |
8736 } | |
8737 } | |
8738 | |
8739 | |
8740 static int trouble_nesting = 0; | 8707 static int trouble_nesting = 0; |
8741 static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 8708 static void TroubleCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
8742 ApiTestFuzzer::Fuzz(); | 8709 ApiTestFuzzer::Fuzz(); |
8743 trouble_nesting++; | 8710 trouble_nesting++; |
8744 | 8711 |
8745 // Call a JS function that throws an uncaught exception. | 8712 // Call a JS function that throws an uncaught exception. |
8746 Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); | 8713 Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); |
8747 Local<v8::Object> arg_this = context->Global(); | 8714 Local<v8::Object> arg_this = context->Global(); |
8748 Local<Value> trouble_callee = | 8715 Local<Value> trouble_callee = |
8749 (trouble_nesting == 3) | 8716 (trouble_nesting == 3) |
(...skipping 5984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14734 // Wait a bit before terminating. | 14701 // Wait a bit before terminating. |
14735 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(50)); | 14702 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(50)); |
14736 v8::V8::TerminateExecution(isolate_); | 14703 v8::V8::TerminateExecution(isolate_); |
14737 } | 14704 } |
14738 | 14705 |
14739 private: | 14706 private: |
14740 v8::Isolate* isolate_; | 14707 v8::Isolate* isolate_; |
14741 }; | 14708 }; |
14742 | 14709 |
14743 | 14710 |
14744 void RunBeforeGC(v8::GCType type, v8::GCCallbackFlags flags) { | 14711 void RunBeforeGC(v8::Isolate* isolate, v8::GCType type, |
| 14712 v8::GCCallbackFlags flags) { |
14745 if (v8::base::NoBarrier_Load(®exp_interruption_data.loop_count) != 2) { | 14713 if (v8::base::NoBarrier_Load(®exp_interruption_data.loop_count) != 2) { |
14746 return; | 14714 return; |
14747 } | 14715 } |
14748 v8::HandleScope scope(CcTest::isolate()); | 14716 v8::HandleScope scope(isolate); |
14749 v8::Local<v8::String> string = v8::Local<v8::String>::New( | 14717 v8::Local<v8::String> string = v8::Local<v8::String>::New( |
14750 CcTest::isolate(), regexp_interruption_data.string); | 14718 CcTest::isolate(), regexp_interruption_data.string); |
14751 string->MakeExternal(regexp_interruption_data.string_resource); | 14719 string->MakeExternal(regexp_interruption_data.string_resource); |
14752 } | 14720 } |
14753 | 14721 |
14754 | 14722 |
14755 // Test that RegExp execution can be interrupted. Specifically, we test | 14723 // Test that RegExp execution can be interrupted. Specifically, we test |
14756 // * interrupting with GC | 14724 // * interrupting with GC |
14757 // * turn the subject string from one-byte internal to two-byte external string | 14725 // * turn the subject string from one-byte internal to two-byte external string |
14758 // * force termination | 14726 // * force termination |
14759 TEST(RegExpInterruption) { | 14727 TEST(RegExpInterruption) { |
14760 v8::HandleScope scope(CcTest::isolate()); | 14728 v8::HandleScope scope(CcTest::isolate()); |
14761 LocalContext env; | 14729 LocalContext env; |
14762 | 14730 |
14763 RegExpInterruptionThread timeout_thread(CcTest::isolate()); | 14731 RegExpInterruptionThread timeout_thread(CcTest::isolate()); |
14764 | 14732 |
14765 v8::V8::AddGCPrologueCallback(RunBeforeGC); | 14733 env->GetIsolate()->AddGCPrologueCallback(RunBeforeGC); |
14766 static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 14734 static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
14767 i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content); | 14735 i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content); |
14768 v8::Local<v8::String> string = v8_str(one_byte_content); | 14736 v8::Local<v8::String> string = v8_str(one_byte_content); |
14769 | 14737 |
14770 CcTest::global()->Set(v8_str("a"), string); | 14738 CcTest::global()->Set(v8_str("a"), string); |
14771 regexp_interruption_data.string.Reset(CcTest::isolate(), string); | 14739 regexp_interruption_data.string.Reset(CcTest::isolate(), string); |
14772 regexp_interruption_data.string_resource = new UC16VectorResource( | 14740 regexp_interruption_data.string_resource = new UC16VectorResource( |
14773 i::Vector<const i::uc16>(uc16_content, i::StrLength(one_byte_content))); | 14741 i::Vector<const i::uc16>(uc16_content, i::StrLength(one_byte_content))); |
14774 | 14742 |
14775 v8::TryCatch try_catch(CcTest::isolate()); | 14743 v8::TryCatch try_catch(CcTest::isolate()); |
(...skipping 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18084 } | 18052 } |
18085 | 18053 |
18086 v8::Isolate* gc_callbacks_isolate = NULL; | 18054 v8::Isolate* gc_callbacks_isolate = NULL; |
18087 int prologue_call_count = 0; | 18055 int prologue_call_count = 0; |
18088 int epilogue_call_count = 0; | 18056 int epilogue_call_count = 0; |
18089 int prologue_call_count_second = 0; | 18057 int prologue_call_count_second = 0; |
18090 int epilogue_call_count_second = 0; | 18058 int epilogue_call_count_second = 0; |
18091 int prologue_call_count_alloc = 0; | 18059 int prologue_call_count_alloc = 0; |
18092 int epilogue_call_count_alloc = 0; | 18060 int epilogue_call_count_alloc = 0; |
18093 | 18061 |
18094 void PrologueCallback(v8::GCType, v8::GCCallbackFlags flags) { | |
18095 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | |
18096 ++prologue_call_count; | |
18097 } | |
18098 | |
18099 | |
18100 void PrologueCallback(v8::Isolate* isolate, | 18062 void PrologueCallback(v8::Isolate* isolate, |
18101 v8::GCType, | 18063 v8::GCType, |
18102 v8::GCCallbackFlags flags) { | 18064 v8::GCCallbackFlags flags) { |
18103 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | 18065 CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
18104 CHECK_EQ(gc_callbacks_isolate, isolate); | 18066 CHECK_EQ(gc_callbacks_isolate, isolate); |
18105 ++prologue_call_count; | 18067 ++prologue_call_count; |
18106 } | 18068 } |
18107 | 18069 |
18108 | |
18109 void EpilogueCallback(v8::GCType, v8::GCCallbackFlags flags) { | |
18110 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | |
18111 ++epilogue_call_count; | |
18112 } | |
18113 | |
18114 | |
18115 void EpilogueCallback(v8::Isolate* isolate, | 18070 void EpilogueCallback(v8::Isolate* isolate, |
18116 v8::GCType, | 18071 v8::GCType, |
18117 v8::GCCallbackFlags flags) { | 18072 v8::GCCallbackFlags flags) { |
18118 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | 18073 CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
18119 CHECK_EQ(gc_callbacks_isolate, isolate); | 18074 CHECK_EQ(gc_callbacks_isolate, isolate); |
18120 ++epilogue_call_count; | 18075 ++epilogue_call_count; |
18121 } | 18076 } |
18122 | 18077 |
18123 | 18078 |
18124 void PrologueCallbackSecond(v8::GCType, v8::GCCallbackFlags flags) { | |
18125 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | |
18126 ++prologue_call_count_second; | |
18127 } | |
18128 | |
18129 | |
18130 void PrologueCallbackSecond(v8::Isolate* isolate, | 18079 void PrologueCallbackSecond(v8::Isolate* isolate, |
18131 v8::GCType, | 18080 v8::GCType, |
18132 v8::GCCallbackFlags flags) { | 18081 v8::GCCallbackFlags flags) { |
18133 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | 18082 CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
18134 CHECK_EQ(gc_callbacks_isolate, isolate); | 18083 CHECK_EQ(gc_callbacks_isolate, isolate); |
18135 ++prologue_call_count_second; | 18084 ++prologue_call_count_second; |
18136 } | 18085 } |
18137 | 18086 |
18138 | 18087 |
18139 void EpilogueCallbackSecond(v8::GCType, v8::GCCallbackFlags flags) { | |
18140 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | |
18141 ++epilogue_call_count_second; | |
18142 } | |
18143 | |
18144 | |
18145 void EpilogueCallbackSecond(v8::Isolate* isolate, | 18088 void EpilogueCallbackSecond(v8::Isolate* isolate, |
18146 v8::GCType, | 18089 v8::GCType, |
18147 v8::GCCallbackFlags flags) { | 18090 v8::GCCallbackFlags flags) { |
18148 CHECK_EQ(flags, v8::kNoGCCallbackFlags); | 18091 CHECK_EQ(flags, v8::kNoGCCallbackFlags); |
18149 CHECK_EQ(gc_callbacks_isolate, isolate); | 18092 CHECK_EQ(gc_callbacks_isolate, isolate); |
18150 ++epilogue_call_count_second; | 18093 ++epilogue_call_count_second; |
18151 } | 18094 } |
18152 | 18095 |
18153 | 18096 |
18154 void PrologueCallbackAlloc(v8::Isolate* isolate, | 18097 void PrologueCallbackAlloc(v8::Isolate* isolate, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18187 CHECK(!obj.IsEmpty()); | 18130 CHECK(!obj.IsEmpty()); |
18188 | 18131 |
18189 CcTest::heap()->CollectAllGarbage( | 18132 CcTest::heap()->CollectAllGarbage( |
18190 i::Heap::kAbortIncrementalMarkingMask); | 18133 i::Heap::kAbortIncrementalMarkingMask); |
18191 } | 18134 } |
18192 | 18135 |
18193 | 18136 |
18194 TEST(GCCallbacksOld) { | 18137 TEST(GCCallbacksOld) { |
18195 LocalContext context; | 18138 LocalContext context; |
18196 | 18139 |
18197 v8::V8::AddGCPrologueCallback(PrologueCallback); | 18140 gc_callbacks_isolate = context->GetIsolate(); |
18198 v8::V8::AddGCEpilogueCallback(EpilogueCallback); | 18141 |
| 18142 context->GetIsolate()->AddGCPrologueCallback(PrologueCallback); |
| 18143 context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallback); |
18199 CHECK_EQ(0, prologue_call_count); | 18144 CHECK_EQ(0, prologue_call_count); |
18200 CHECK_EQ(0, epilogue_call_count); | 18145 CHECK_EQ(0, epilogue_call_count); |
18201 CcTest::heap()->CollectAllGarbage(); | 18146 CcTest::heap()->CollectAllGarbage(); |
18202 CHECK_EQ(1, prologue_call_count); | 18147 CHECK_EQ(1, prologue_call_count); |
18203 CHECK_EQ(1, epilogue_call_count); | 18148 CHECK_EQ(1, epilogue_call_count); |
18204 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); | 18149 context->GetIsolate()->AddGCPrologueCallback(PrologueCallbackSecond); |
18205 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); | 18150 context->GetIsolate()->AddGCEpilogueCallback(EpilogueCallbackSecond); |
18206 CcTest::heap()->CollectAllGarbage(); | 18151 CcTest::heap()->CollectAllGarbage(); |
18207 CHECK_EQ(2, prologue_call_count); | 18152 CHECK_EQ(2, prologue_call_count); |
18208 CHECK_EQ(2, epilogue_call_count); | 18153 CHECK_EQ(2, epilogue_call_count); |
18209 CHECK_EQ(1, prologue_call_count_second); | 18154 CHECK_EQ(1, prologue_call_count_second); |
18210 CHECK_EQ(1, epilogue_call_count_second); | 18155 CHECK_EQ(1, epilogue_call_count_second); |
18211 v8::V8::RemoveGCPrologueCallback(PrologueCallback); | 18156 context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallback); |
18212 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); | 18157 context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallback); |
18213 CcTest::heap()->CollectAllGarbage(); | 18158 CcTest::heap()->CollectAllGarbage(); |
18214 CHECK_EQ(2, prologue_call_count); | 18159 CHECK_EQ(2, prologue_call_count); |
18215 CHECK_EQ(2, epilogue_call_count); | 18160 CHECK_EQ(2, epilogue_call_count); |
18216 CHECK_EQ(2, prologue_call_count_second); | 18161 CHECK_EQ(2, prologue_call_count_second); |
18217 CHECK_EQ(2, epilogue_call_count_second); | 18162 CHECK_EQ(2, epilogue_call_count_second); |
18218 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); | 18163 context->GetIsolate()->RemoveGCPrologueCallback(PrologueCallbackSecond); |
18219 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); | 18164 context->GetIsolate()->RemoveGCEpilogueCallback(EpilogueCallbackSecond); |
18220 CcTest::heap()->CollectAllGarbage(); | 18165 CcTest::heap()->CollectAllGarbage(); |
18221 CHECK_EQ(2, prologue_call_count); | 18166 CHECK_EQ(2, prologue_call_count); |
18222 CHECK_EQ(2, epilogue_call_count); | 18167 CHECK_EQ(2, epilogue_call_count); |
18223 CHECK_EQ(2, prologue_call_count_second); | 18168 CHECK_EQ(2, prologue_call_count_second); |
18224 CHECK_EQ(2, epilogue_call_count_second); | 18169 CHECK_EQ(2, epilogue_call_count_second); |
18225 } | 18170 } |
18226 | 18171 |
18227 | 18172 |
18228 TEST(GCCallbacks) { | 18173 TEST(GCCallbacks) { |
18229 LocalContext context; | 18174 LocalContext context; |
(...skipping 5654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23884 env2->Global()->Set(env2.local(), v8_str("obj2"), object2).FromJust()); | 23829 env2->Global()->Set(env2.local(), v8_str("obj2"), object2).FromJust()); |
23885 ExpectString("typeof obj2.values", "function"); | 23830 ExpectString("typeof obj2.values", "function"); |
23886 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); | 23831 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); |
23887 | 23832 |
23888 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); | 23833 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); |
23889 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); | 23834 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); |
23890 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); | 23835 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); |
23891 CHECK_EQ(fn2->GetCreationContext(), *ctx2); | 23836 CHECK_EQ(fn2->GetCreationContext(), *ctx2); |
23892 } | 23837 } |
23893 } | 23838 } |
OLD | NEW |