OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 6199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6210 const char* extension_list[] = { "v8/gc" }; | 6210 const char* extension_list[] = { "v8/gc" }; |
6211 v8::ExtensionConfiguration extensions(1, extension_list); | 6211 v8::ExtensionConfiguration extensions(1, extension_list); |
6212 LocalContext context(&extensions); | 6212 LocalContext context(&extensions); |
6213 v8_compile("gc();")->Run(); | 6213 v8_compile("gc();")->Run(); |
6214 } | 6214 } |
6215 CHECK_EQ(count, GetSurvivingGlobalObjectsCount()); | 6215 CHECK_EQ(count, GetSurvivingGlobalObjectsCount()); |
6216 } | 6216 } |
6217 } | 6217 } |
6218 | 6218 |
6219 | 6219 |
| 6220 v8::Persistent<v8::Object> some_object; |
| 6221 v8::Persistent<v8::Object> bad_handle; |
| 6222 |
| 6223 void NewPersistentHandleCallback(v8::Persistent<v8::Value>, void*) { |
| 6224 v8::HandleScope scope; |
| 6225 bad_handle = v8::Persistent<v8::Object>::New(some_object); |
| 6226 } |
| 6227 |
| 6228 |
| 6229 THREADED_TEST(NewPersistentHandleFromWeakCallback) { |
| 6230 LocalContext context; |
| 6231 |
| 6232 v8::Persistent<v8::Object> handle1, handle2; |
| 6233 { |
| 6234 v8::HandleScope scope; |
| 6235 some_object = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 6236 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 6237 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 6238 } |
| 6239 // Note: order is implementation dependent alas: currently |
| 6240 // global handle nodes are processed by PostGarbageCollectionProcessing |
| 6241 // in reverse allocation order, so if second allocated handle is deleted, |
| 6242 // weak callback of the first handle would be able to 'reallocate' it. |
| 6243 handle1.MakeWeak(NULL, NewPersistentHandleCallback); |
| 6244 handle2.Dispose(); |
| 6245 i::Heap::CollectAllGarbage(); |
| 6246 } |
| 6247 |
| 6248 |
6220 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 6249 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
6221 v8::V8::Initialize(); | 6250 v8::V8::Initialize(); |
6222 | 6251 |
6223 const int nof = 2; | 6252 const int nof = 2; |
6224 const char* sources[nof] = { | 6253 const char* sources[nof] = { |
6225 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", | 6254 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", |
6226 "Object()" | 6255 "Object()" |
6227 }; | 6256 }; |
6228 | 6257 |
6229 for (int i = 0; i < nof; i++) { | 6258 for (int i = 0; i < nof; i++) { |
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7759 LocalContext context; | 7788 LocalContext context; |
7760 v8::TryCatch try_catch; | 7789 v8::TryCatch try_catch; |
7761 const char *source = "function foo() { FAIL.FAIL; }; foo();"; | 7790 const char *source = "function foo() { FAIL.FAIL; }; foo();"; |
7762 v8::Handle<v8::String> src = v8::String::New(source); | 7791 v8::Handle<v8::String> src = v8::String::New(source); |
7763 v8::Handle<v8::String> origin = v8::String::New("stack-trace-test"); | 7792 v8::Handle<v8::String> origin = v8::String::New("stack-trace-test"); |
7764 v8::Script::New(src, origin)->Run(); | 7793 v8::Script::New(src, origin)->Run(); |
7765 CHECK(try_catch.HasCaught()); | 7794 CHECK(try_catch.HasCaught()); |
7766 v8::String::Utf8Value stack(try_catch.StackTrace()); | 7795 v8::String::Utf8Value stack(try_catch.StackTrace()); |
7767 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); | 7796 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); |
7768 } | 7797 } |
OLD | NEW |