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

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

Issue 17642011: Reland "Remove IsInitialized checks from inlined API functions." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | « src/isolate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18808 matching lines...) Expand 10 before | Expand all | Expand 10 after
18819 TEST(SecondaryStubCache) { 18819 TEST(SecondaryStubCache) {
18820 StubCacheHelper(true); 18820 StubCacheHelper(true);
18821 } 18821 }
18822 18822
18823 18823
18824 TEST(PrimaryStubCache) { 18824 TEST(PrimaryStubCache) {
18825 StubCacheHelper(false); 18825 StubCacheHelper(false);
18826 } 18826 }
18827 18827
18828 18828
18829 static int fatal_error_callback_counter = 0;
18830 static void CountingErrorCallback(const char* location, const char* message) {
18831 printf("CountingErrorCallback(\"%s\", \"%s\")\n", location, message);
18832 fatal_error_callback_counter++;
18833 }
18834
18835
18836 TEST(StaticGetters) { 18829 TEST(StaticGetters) {
18837 LocalContext context; 18830 LocalContext context;
18838 i::Factory* factory = i::Isolate::Current()->factory(); 18831 i::Factory* factory = i::Isolate::Current()->factory();
18839 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 18832 v8::Isolate* isolate = v8::Isolate::GetCurrent();
18840 v8::HandleScope scope(isolate); 18833 v8::HandleScope scope(isolate);
18841 i::Handle<i::Object> undefined_value = factory->undefined_value(); 18834 i::Handle<i::Object> undefined_value = factory->undefined_value();
18842 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value); 18835 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value);
18843 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); 18836 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value);
18844 i::Handle<i::Object> null_value = factory->null_value(); 18837 i::Handle<i::Object> null_value = factory->null_value();
18845 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value); 18838 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value);
18846 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); 18839 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value);
18847 i::Handle<i::Object> true_value = factory->true_value(); 18840 i::Handle<i::Object> true_value = factory->true_value();
18848 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); 18841 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
18849 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); 18842 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
18850 i::Handle<i::Object> false_value = factory->false_value(); 18843 i::Handle<i::Object> false_value = factory->false_value();
18851 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); 18844 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
18852 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); 18845 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
18853
18854 // Test after-death behavior.
18855 CHECK(i::Internals::IsInitialized(isolate));
18856 CHECK_EQ(0, fatal_error_callback_counter);
18857 v8::V8::SetFatalErrorHandler(CountingErrorCallback);
18858 v8::Utils::ReportApiFailure("StaticGetters()", "Kill V8");
18859 i::Isolate::Current()->TearDown();
18860 CHECK(!i::Internals::IsInitialized(isolate));
18861 CHECK_EQ(1, fatal_error_callback_counter);
18862 CHECK(v8::Undefined().IsEmpty());
18863 CHECK_EQ(2, fatal_error_callback_counter);
18864 CHECK(v8::Undefined(isolate).IsEmpty());
18865 CHECK_EQ(3, fatal_error_callback_counter);
18866 CHECK(v8::Null().IsEmpty());
18867 CHECK_EQ(4, fatal_error_callback_counter);
18868 CHECK(v8::Null(isolate).IsEmpty());
18869 CHECK_EQ(5, fatal_error_callback_counter);
18870 CHECK(v8::True().IsEmpty());
18871 CHECK_EQ(6, fatal_error_callback_counter);
18872 CHECK(v8::True(isolate).IsEmpty());
18873 CHECK_EQ(7, fatal_error_callback_counter);
18874 CHECK(v8::False().IsEmpty());
18875 CHECK_EQ(8, fatal_error_callback_counter);
18876 CHECK(v8::False(isolate).IsEmpty());
18877 CHECK_EQ(9, fatal_error_callback_counter);
18878 } 18846 }
18879 18847
18880 18848
18881 TEST(IsolateEmbedderData) { 18849 TEST(IsolateEmbedderData) {
18882 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 18850 v8::Isolate* isolate = v8::Isolate::GetCurrent();
18883 CHECK_EQ(NULL, isolate->GetData()); 18851 CHECK_EQ(NULL, isolate->GetData());
18884 CHECK_EQ(NULL, ISOLATE->GetData()); 18852 CHECK_EQ(NULL, ISOLATE->GetData());
18885 static void* data1 = reinterpret_cast<void*>(0xacce55ed); 18853 static void* data1 = reinterpret_cast<void*>(0xacce55ed);
18886 isolate->SetData(data1); 18854 isolate->SetData(data1);
18887 CHECK_EQ(data1, isolate->GetData()); 18855 CHECK_EQ(data1, isolate->GetData());
18888 CHECK_EQ(data1, ISOLATE->GetData()); 18856 CHECK_EQ(data1, ISOLATE->GetData());
18889 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); 18857 static void* data2 = reinterpret_cast<void*>(0xdecea5ed);
18890 ISOLATE->SetData(data2); 18858 ISOLATE->SetData(data2);
18891 CHECK_EQ(data2, isolate->GetData()); 18859 CHECK_EQ(data2, isolate->GetData());
18892 CHECK_EQ(data2, ISOLATE->GetData()); 18860 CHECK_EQ(data2, ISOLATE->GetData());
18893 ISOLATE->TearDown(); 18861 ISOLATE->TearDown();
18894 CHECK_EQ(data2, isolate->GetData()); 18862 CHECK_EQ(data2, isolate->GetData());
18895 CHECK_EQ(data2, ISOLATE->GetData()); 18863 CHECK_EQ(data2, ISOLATE->GetData());
18896 } 18864 }
18897 18865
18898 18866
18899 TEST(StringEmpty) { 18867 TEST(StringEmpty) {
18900 LocalContext context; 18868 LocalContext context;
18901 i::Factory* factory = i::Isolate::Current()->factory(); 18869 i::Factory* factory = i::Isolate::Current()->factory();
18902 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 18870 v8::Isolate* isolate = v8::Isolate::GetCurrent();
18903 v8::HandleScope scope(isolate); 18871 v8::HandleScope scope(isolate);
18904 i::Handle<i::Object> empty_string = factory->empty_string(); 18872 i::Handle<i::Object> empty_string = factory->empty_string();
18905 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); 18873 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
18906 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); 18874 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string);
18907
18908 // Test after-death behavior.
18909 CHECK(i::Internals::IsInitialized(isolate));
18910 CHECK_EQ(0, fatal_error_callback_counter);
18911 v8::V8::SetFatalErrorHandler(CountingErrorCallback);
18912 v8::Utils::ReportApiFailure("StringEmpty()", "Kill V8");
18913 i::Isolate::Current()->TearDown();
18914 CHECK(!i::Internals::IsInitialized(isolate));
18915 CHECK_EQ(1, fatal_error_callback_counter);
18916 CHECK(v8::String::Empty().IsEmpty());
18917 CHECK_EQ(2, fatal_error_callback_counter);
18918 CHECK(v8::String::Empty(isolate).IsEmpty());
18919 CHECK_EQ(3, fatal_error_callback_counter);
18920 } 18875 }
18921 18876
18922 18877
18923 static int instance_checked_getter_count = 0; 18878 static int instance_checked_getter_count = 0;
18924 static void InstanceCheckedGetter( 18879 static void InstanceCheckedGetter(
18925 Local<String> name, 18880 Local<String> name,
18926 const v8::PropertyCallbackInfo<v8::Value>& info) { 18881 const v8::PropertyCallbackInfo<v8::Value>& info) {
18927 CHECK_EQ(name, v8_str("foo")); 18882 CHECK_EQ(name, v8_str("foo"));
18928 instance_checked_getter_count++; 18883 instance_checked_getter_count++;
18929 info.GetReturnValue().Set(v8_num(11)); 18884 info.GetReturnValue().Set(v8_num(11));
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
19381 i::Semaphore* sem_; 19336 i::Semaphore* sem_;
19382 volatile int sem_value_; 19337 volatile int sem_value_;
19383 }; 19338 };
19384 19339
19385 19340
19386 THREADED_TEST(SemaphoreInterruption) { 19341 THREADED_TEST(SemaphoreInterruption) {
19387 ThreadInterruptTest().RunTest(); 19342 ThreadInterruptTest().RunTest();
19388 } 19343 }
19389 19344
19390 #endif // WIN32 19345 #endif // WIN32
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698