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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
| 28 // We want to test our deprecated API entries, too. |
| 29 #define V8_DISABLE_DEPRECATIONS 1 |
| 30 |
28 #include <limits.h> | 31 #include <limits.h> |
29 | 32 |
30 #ifndef WIN32 | 33 #ifndef WIN32 |
31 #include <signal.h> // kill | 34 #include <signal.h> // kill |
32 #include <unistd.h> // getpid | 35 #include <unistd.h> // getpid |
33 #endif // WIN32 | 36 #endif // WIN32 |
34 | 37 |
35 #include "v8.h" | 38 #include "v8.h" |
36 | 39 |
37 #include "api.h" | 40 #include "api.h" |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 Local<Function> fun = fun_templ->GetFunction(); | 880 Local<Function> fun = fun_templ->GetFunction(); |
878 env->Global()->Set(v8_str("obj"), fun); | 881 env->Global()->Set(v8_str("obj"), fun); |
879 Local<Script> script = v8_compile("obj.length"); | 882 Local<Script> script = v8_compile("obj.length"); |
880 CHECK_EQ(0, script->Run()->Int32Value()); | 883 CHECK_EQ(0, script->Run()->Int32Value()); |
881 } | 884 } |
882 } | 885 } |
883 | 886 |
884 | 887 |
885 static void* expected_ptr; | 888 static void* expected_ptr; |
886 static v8::Handle<v8::Value> callback(const v8::Arguments& args) { | 889 static v8::Handle<v8::Value> callback(const v8::Arguments& args) { |
887 void* ptr = v8::External::Cast(*args.Data())->Value(); | 890 void* ptr = v8::External::Unwrap(args.Data()); |
888 CHECK_EQ(expected_ptr, ptr); | 891 CHECK_EQ(expected_ptr, ptr); |
889 return v8::True(); | 892 return v8::True(); |
890 } | 893 } |
891 | 894 |
892 | 895 |
893 static void TestExternalPointerWrapping() { | 896 static void TestExternalPointerWrapping() { |
894 v8::HandleScope scope; | 897 v8::HandleScope scope; |
895 LocalContext env; | 898 LocalContext env; |
896 | 899 |
897 v8::Handle<v8::Value> data = v8::External::New(expected_ptr); | 900 v8::Handle<v8::Value> data = v8::External::Wrap(expected_ptr); |
898 | 901 |
899 v8::Handle<v8::Object> obj = v8::Object::New(); | 902 v8::Handle<v8::Object> obj = v8::Object::New(); |
900 obj->Set(v8_str("func"), | 903 obj->Set(v8_str("func"), |
901 v8::FunctionTemplate::New(callback, data)->GetFunction()); | 904 v8::FunctionTemplate::New(callback, data)->GetFunction()); |
902 env->Global()->Set(v8_str("obj"), obj); | 905 env->Global()->Set(v8_str("obj"), obj); |
903 | 906 |
904 CHECK(CompileRun( | 907 CHECK(CompileRun( |
905 "function foo() {\n" | 908 "function foo() {\n" |
906 " for (var i = 0; i < 13; i++) obj.func();\n" | 909 " for (var i = 0; i < 13; i++) obj.func();\n" |
907 "}\n" | 910 "}\n" |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 LocalContext env(NULL, global_template); | 2018 LocalContext env(NULL, global_template); |
2016 v8::Handle<v8::Object> global_proxy = env->Global(); | 2019 v8::Handle<v8::Object> global_proxy = env->Global(); |
2017 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); | 2020 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
2018 CHECK_EQ(1, global->InternalFieldCount()); | 2021 CHECK_EQ(1, global->InternalFieldCount()); |
2019 CHECK(global->GetInternalField(0)->IsUndefined()); | 2022 CHECK(global->GetInternalField(0)->IsUndefined()); |
2020 global->SetInternalField(0, v8_num(17)); | 2023 global->SetInternalField(0, v8_num(17)); |
2021 CHECK_EQ(17, global->GetInternalField(0)->Int32Value()); | 2024 CHECK_EQ(17, global->GetInternalField(0)->Int32Value()); |
2022 } | 2025 } |
2023 | 2026 |
2024 | 2027 |
| 2028 THREADED_TEST(InternalFieldsNativePointers) { |
| 2029 v8::HandleScope scope; |
| 2030 LocalContext env; |
| 2031 |
| 2032 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 2033 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 2034 instance_templ->SetInternalFieldCount(1); |
| 2035 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); |
| 2036 CHECK_EQ(1, obj->InternalFieldCount()); |
| 2037 CHECK(obj->GetPointerFromInternalField(0) == NULL); |
| 2038 |
| 2039 char* data = new char[100]; |
| 2040 |
| 2041 void* aligned = data; |
| 2042 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1)); |
| 2043 void* unaligned = data + 1; |
| 2044 CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); |
| 2045 |
| 2046 // Check reading and writing aligned pointers. |
| 2047 obj->SetPointerInInternalField(0, aligned); |
| 2048 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2049 CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); |
| 2050 |
| 2051 // Check reading and writing unaligned pointers. |
| 2052 obj->SetPointerInInternalField(0, unaligned); |
| 2053 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2054 CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); |
| 2055 |
| 2056 delete[] data; |
| 2057 } |
| 2058 |
| 2059 |
| 2060 THREADED_TEST(InternalFieldsNativePointersAndExternal) { |
| 2061 v8::HandleScope scope; |
| 2062 LocalContext env; |
| 2063 |
| 2064 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 2065 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 2066 instance_templ->SetInternalFieldCount(1); |
| 2067 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); |
| 2068 CHECK_EQ(1, obj->InternalFieldCount()); |
| 2069 CHECK(obj->GetPointerFromInternalField(0) == NULL); |
| 2070 |
| 2071 char* data = new char[100]; |
| 2072 |
| 2073 void* aligned = data; |
| 2074 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1)); |
| 2075 void* unaligned = data + 1; |
| 2076 CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); |
| 2077 |
| 2078 obj->SetPointerInInternalField(0, aligned); |
| 2079 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2080 CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0))); |
| 2081 |
| 2082 obj->SetPointerInInternalField(0, unaligned); |
| 2083 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2084 CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0))); |
| 2085 |
| 2086 obj->SetInternalField(0, v8::External::Wrap(aligned)); |
| 2087 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2088 CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); |
| 2089 |
| 2090 obj->SetInternalField(0, v8::External::Wrap(unaligned)); |
| 2091 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2092 CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); |
| 2093 |
| 2094 delete[] data; |
| 2095 } |
| 2096 |
| 2097 |
2025 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, | 2098 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, |
2026 void* value) { | 2099 void* value) { |
2027 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2100 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
2028 obj->SetAlignedPointerInInternalField(0, value); | 2101 obj->SetPointerInInternalField(0, value); |
2029 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2102 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
2030 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); | 2103 CHECK_EQ(value, obj->GetPointerFromInternalField(0)); |
2031 } | 2104 } |
2032 | 2105 |
2033 | 2106 |
2034 THREADED_TEST(InternalFieldsAlignedPointers) { | 2107 THREADED_TEST(InternalFieldsAlignedPointers) { |
2035 v8::HandleScope scope; | 2108 v8::HandleScope scope; |
2036 LocalContext env; | 2109 LocalContext env; |
2037 | 2110 |
2038 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2111 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
2039 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 2112 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
2040 instance_templ->SetInternalFieldCount(1); | 2113 instance_templ->SetInternalFieldCount(1); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2275 env->Global()->Set(v8_str("ext"), ext); | 2348 env->Global()->Set(v8_str("ext"), ext); |
2276 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); | 2349 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
2277 v8::Handle<v8::External> reext = reext_obj.As<v8::External>(); | 2350 v8::Handle<v8::External> reext = reext_obj.As<v8::External>(); |
2278 int* ptr = static_cast<int*>(reext->Value()); | 2351 int* ptr = static_cast<int*>(reext->Value()); |
2279 CHECK_EQ(x, 3); | 2352 CHECK_EQ(x, 3); |
2280 *ptr = 10; | 2353 *ptr = 10; |
2281 CHECK_EQ(x, 10); | 2354 CHECK_EQ(x, 10); |
2282 | 2355 |
2283 // Make sure unaligned pointers are wrapped properly. | 2356 // Make sure unaligned pointers are wrapped properly. |
2284 char* data = i::StrDup("0123456789"); | 2357 char* data = i::StrDup("0123456789"); |
2285 Local<v8::Value> zero = v8::External::New(&data[0]); | 2358 Local<v8::Value> zero = v8::External::Wrap(&data[0]); |
2286 Local<v8::Value> one = v8::External::New(&data[1]); | 2359 Local<v8::Value> one = v8::External::Wrap(&data[1]); |
2287 Local<v8::Value> two = v8::External::New(&data[2]); | 2360 Local<v8::Value> two = v8::External::Wrap(&data[2]); |
2288 Local<v8::Value> three = v8::External::New(&data[3]); | 2361 Local<v8::Value> three = v8::External::Wrap(&data[3]); |
2289 | 2362 |
2290 char* char_ptr = reinterpret_cast<char*>(v8::External::Cast(*zero)->Value()); | 2363 char* char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(zero)); |
2291 CHECK_EQ('0', *char_ptr); | 2364 CHECK_EQ('0', *char_ptr); |
2292 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*one)->Value()); | 2365 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(one)); |
2293 CHECK_EQ('1', *char_ptr); | 2366 CHECK_EQ('1', *char_ptr); |
2294 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*two)->Value()); | 2367 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(two)); |
2295 CHECK_EQ('2', *char_ptr); | 2368 CHECK_EQ('2', *char_ptr); |
2296 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*three)->Value()); | 2369 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(three)); |
2297 CHECK_EQ('3', *char_ptr); | 2370 CHECK_EQ('3', *char_ptr); |
2298 i::DeleteArray(data); | 2371 i::DeleteArray(data); |
2299 } | 2372 } |
2300 | 2373 |
2301 | 2374 |
2302 THREADED_TEST(GlobalHandle) { | 2375 THREADED_TEST(GlobalHandle) { |
2303 v8::Persistent<String> global; | 2376 v8::Persistent<String> global; |
2304 { | 2377 { |
2305 v8::HandleScope scope; | 2378 v8::HandleScope scope; |
2306 Local<String> str = v8_str("str"); | 2379 Local<String> str = v8_str("str"); |
(...skipping 3906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6213 int len) { | 6286 int len) { |
6214 Local<v8::Array> a = | 6287 Local<v8::Array> a = |
6215 Local<v8::Array>::Cast(context->Global()->Get(v8_str(name))); | 6288 Local<v8::Array>::Cast(context->Global()->Get(v8_str(name))); |
6216 Local<v8::Array> alens = | 6289 Local<v8::Array> alens = |
6217 Local<v8::Array>::Cast(context->Global()->Get(v8_str(lengths_name))); | 6290 Local<v8::Array>::Cast(context->Global()->Get(v8_str(lengths_name))); |
6218 for (int i = 0; i < len; i++) { | 6291 for (int i = 0; i < len; i++) { |
6219 Local<v8::String> string = | 6292 Local<v8::String> string = |
6220 Local<v8::String>::Cast(a->Get(i)); | 6293 Local<v8::String>::Cast(a->Get(i)); |
6221 Local<v8::Number> expected_len = | 6294 Local<v8::Number> expected_len = |
6222 Local<v8::Number>::Cast(alens->Get(i)); | 6295 Local<v8::Number>::Cast(alens->Get(i)); |
6223 #ifndef ENABLE_LATIN_1 | |
6224 CHECK_EQ(expected_len->Value() != string->Length(), | 6296 CHECK_EQ(expected_len->Value() != string->Length(), |
6225 string->MayContainNonAscii()); | 6297 string->MayContainNonAscii()); |
6226 #endif | |
6227 int length = GetUtf8Length(string); | 6298 int length = GetUtf8Length(string); |
6228 CHECK_EQ(static_cast<int>(expected_len->Value()), length); | 6299 CHECK_EQ(static_cast<int>(expected_len->Value()), length); |
6229 } | 6300 } |
6230 } | 6301 } |
6231 | 6302 |
6232 | 6303 |
6233 static uint16_t StringGet(Handle<String> str, int index) { | 6304 static uint16_t StringGet(Handle<String> str, int index) { |
6234 i::Handle<i::String> istring = | 6305 i::Handle<i::String> istring = |
6235 v8::Utils::OpenHandle(String::Cast(*str)); | 6306 v8::Utils::OpenHandle(String::Cast(*str)); |
6236 return istring->Get(index); | 6307 return istring->Get(index); |
(...skipping 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9826 " result" | 9897 " result" |
9827 "} catch(e) {" | 9898 "} catch(e) {" |
9828 " e" | 9899 " e" |
9829 "};"); | 9900 "};"); |
9830 CHECK_EQ(239 * 10, value->Int32Value()); | 9901 CHECK_EQ(239 * 10, value->Int32Value()); |
9831 } | 9902 } |
9832 | 9903 |
9833 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name, | 9904 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name, |
9834 const AccessorInfo& info) { | 9905 const AccessorInfo& info) { |
9835 ApiTestFuzzer::Fuzz(); | 9906 ApiTestFuzzer::Fuzz(); |
9836 int* call_count = | 9907 int* call_count = reinterpret_cast<int*>(v8::External::Unwrap(info.Data())); |
9837 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); | |
9838 ++(*call_count); | 9908 ++(*call_count); |
9839 if ((*call_count) % 20 == 0) { | 9909 if ((*call_count) % 20 == 0) { |
9840 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 9910 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
9841 } | 9911 } |
9842 return v8::Handle<Value>(); | 9912 return v8::Handle<Value>(); |
9843 } | 9913 } |
9844 | 9914 |
9845 static v8::Handle<Value> FastApiCallback_TrivialSignature( | 9915 static v8::Handle<Value> FastApiCallback_TrivialSignature( |
9846 const v8::Arguments& args) { | 9916 const v8::Arguments& args) { |
9847 ApiTestFuzzer::Fuzz(); | 9917 ApiTestFuzzer::Fuzz(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9986 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 10056 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
9987 v8::Handle<v8::FunctionTemplate> method_templ = | 10057 v8::Handle<v8::FunctionTemplate> method_templ = |
9988 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, | 10058 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, |
9989 v8_str("method_data"), | 10059 v8_str("method_data"), |
9990 v8::Handle<v8::Signature>()); | 10060 v8::Handle<v8::Signature>()); |
9991 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10061 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
9992 proto_templ->Set(v8_str("method"), method_templ); | 10062 proto_templ->Set(v8_str("method"), method_templ); |
9993 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10063 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
9994 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 10064 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
9995 NULL, NULL, NULL, NULL, | 10065 NULL, NULL, NULL, NULL, |
9996 v8::External::New(&interceptor_call_count)); | 10066 v8::External::Wrap(&interceptor_call_count)); |
9997 LocalContext context; | 10067 LocalContext context; |
9998 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10068 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
9999 GenerateSomeGarbage(); | 10069 GenerateSomeGarbage(); |
10000 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10070 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
10001 CompileRun( | 10071 CompileRun( |
10002 "var result = 0;" | 10072 "var result = 0;" |
10003 "for (var i = 0; i < 100; i++) {" | 10073 "for (var i = 0; i < 100; i++) {" |
10004 " result = o.method(41);" | 10074 " result = o.method(41);" |
10005 "}"); | 10075 "}"); |
10006 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 10076 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
10007 CHECK_EQ(100, interceptor_call_count); | 10077 CHECK_EQ(100, interceptor_call_count); |
10008 } | 10078 } |
10009 | 10079 |
10010 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) { | 10080 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) { |
10011 int interceptor_call_count = 0; | 10081 int interceptor_call_count = 0; |
10012 v8::HandleScope scope; | 10082 v8::HandleScope scope; |
10013 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 10083 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
10014 v8::Handle<v8::FunctionTemplate> method_templ = | 10084 v8::Handle<v8::FunctionTemplate> method_templ = |
10015 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 10085 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
10016 v8_str("method_data"), | 10086 v8_str("method_data"), |
10017 v8::Signature::New(fun_templ)); | 10087 v8::Signature::New(fun_templ)); |
10018 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10088 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
10019 proto_templ->Set(v8_str("method"), method_templ); | 10089 proto_templ->Set(v8_str("method"), method_templ); |
10020 fun_templ->SetHiddenPrototype(true); | 10090 fun_templ->SetHiddenPrototype(true); |
10021 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10091 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
10022 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 10092 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
10023 NULL, NULL, NULL, NULL, | 10093 NULL, NULL, NULL, NULL, |
10024 v8::External::New(&interceptor_call_count)); | 10094 v8::External::Wrap(&interceptor_call_count)); |
10025 LocalContext context; | 10095 LocalContext context; |
10026 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10096 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
10027 GenerateSomeGarbage(); | 10097 GenerateSomeGarbage(); |
10028 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10098 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
10029 CompileRun( | 10099 CompileRun( |
10030 "o.foo = 17;" | 10100 "o.foo = 17;" |
10031 "var receiver = {};" | 10101 "var receiver = {};" |
10032 "receiver.__proto__ = o;" | 10102 "receiver.__proto__ = o;" |
10033 "var result = 0;" | 10103 "var result = 0;" |
10034 "for (var i = 0; i < 100; i++) {" | 10104 "for (var i = 0; i < 100; i++) {" |
(...skipping 10 matching lines...) Expand all Loading... |
10045 v8::Handle<v8::FunctionTemplate> method_templ = | 10115 v8::Handle<v8::FunctionTemplate> method_templ = |
10046 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 10116 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
10047 v8_str("method_data"), | 10117 v8_str("method_data"), |
10048 v8::Signature::New(fun_templ)); | 10118 v8::Signature::New(fun_templ)); |
10049 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10119 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
10050 proto_templ->Set(v8_str("method"), method_templ); | 10120 proto_templ->Set(v8_str("method"), method_templ); |
10051 fun_templ->SetHiddenPrototype(true); | 10121 fun_templ->SetHiddenPrototype(true); |
10052 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10122 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
10053 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 10123 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
10054 NULL, NULL, NULL, NULL, | 10124 NULL, NULL, NULL, NULL, |
10055 v8::External::New(&interceptor_call_count)); | 10125 v8::External::Wrap(&interceptor_call_count)); |
10056 LocalContext context; | 10126 LocalContext context; |
10057 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10127 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
10058 GenerateSomeGarbage(); | 10128 GenerateSomeGarbage(); |
10059 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10129 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
10060 CompileRun( | 10130 CompileRun( |
10061 "o.foo = 17;" | 10131 "o.foo = 17;" |
10062 "var receiver = {};" | 10132 "var receiver = {};" |
10063 "receiver.__proto__ = o;" | 10133 "receiver.__proto__ = o;" |
10064 "var result = 0;" | 10134 "var result = 0;" |
10065 "var saved_result = 0;" | 10135 "var saved_result = 0;" |
(...skipping 16 matching lines...) Expand all Loading... |
10082 v8::Handle<v8::FunctionTemplate> method_templ = | 10152 v8::Handle<v8::FunctionTemplate> method_templ = |
10083 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 10153 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
10084 v8_str("method_data"), | 10154 v8_str("method_data"), |
10085 v8::Signature::New(fun_templ)); | 10155 v8::Signature::New(fun_templ)); |
10086 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10156 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
10087 proto_templ->Set(v8_str("method"), method_templ); | 10157 proto_templ->Set(v8_str("method"), method_templ); |
10088 fun_templ->SetHiddenPrototype(true); | 10158 fun_templ->SetHiddenPrototype(true); |
10089 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10159 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
10090 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 10160 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
10091 NULL, NULL, NULL, NULL, | 10161 NULL, NULL, NULL, NULL, |
10092 v8::External::New(&interceptor_call_count)); | 10162 v8::External::Wrap(&interceptor_call_count)); |
10093 LocalContext context; | 10163 LocalContext context; |
10094 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10164 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
10095 GenerateSomeGarbage(); | 10165 GenerateSomeGarbage(); |
10096 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10166 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
10097 CompileRun( | 10167 CompileRun( |
10098 "o.foo = 17;" | 10168 "o.foo = 17;" |
10099 "var receiver = {};" | 10169 "var receiver = {};" |
10100 "receiver.__proto__ = o;" | 10170 "receiver.__proto__ = o;" |
10101 "var result = 0;" | 10171 "var result = 0;" |
10102 "var saved_result = 0;" | 10172 "var saved_result = 0;" |
(...skipping 16 matching lines...) Expand all Loading... |
10119 v8::Handle<v8::FunctionTemplate> method_templ = | 10189 v8::Handle<v8::FunctionTemplate> method_templ = |
10120 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 10190 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
10121 v8_str("method_data"), | 10191 v8_str("method_data"), |
10122 v8::Signature::New(fun_templ)); | 10192 v8::Signature::New(fun_templ)); |
10123 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10193 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
10124 proto_templ->Set(v8_str("method"), method_templ); | 10194 proto_templ->Set(v8_str("method"), method_templ); |
10125 fun_templ->SetHiddenPrototype(true); | 10195 fun_templ->SetHiddenPrototype(true); |
10126 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10196 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
10127 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 10197 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
10128 NULL, NULL, NULL, NULL, | 10198 NULL, NULL, NULL, NULL, |
10129 v8::External::New(&interceptor_call_count)); | 10199 v8::External::Wrap(&interceptor_call_count)); |
10130 LocalContext context; | 10200 LocalContext context; |
10131 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10201 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
10132 GenerateSomeGarbage(); | 10202 GenerateSomeGarbage(); |
10133 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10203 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
10134 v8::TryCatch try_catch; | 10204 v8::TryCatch try_catch; |
10135 CompileRun( | 10205 CompileRun( |
10136 "o.foo = 17;" | 10206 "o.foo = 17;" |
10137 "var receiver = {};" | 10207 "var receiver = {};" |
10138 "receiver.__proto__ = o;" | 10208 "receiver.__proto__ = o;" |
10139 "var result = 0;" | 10209 "var result = 0;" |
(...skipping 19 matching lines...) Expand all Loading... |
10159 v8::Handle<v8::FunctionTemplate> method_templ = | 10229 v8::Handle<v8::FunctionTemplate> method_templ = |
10160 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 10230 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
10161 v8_str("method_data"), | 10231 v8_str("method_data"), |
10162 v8::Signature::New(fun_templ)); | 10232 v8::Signature::New(fun_templ)); |
10163 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 10233 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
10164 proto_templ->Set(v8_str("method"), method_templ); | 10234 proto_templ->Set(v8_str("method"), method_templ); |
10165 fun_templ->SetHiddenPrototype(true); | 10235 fun_templ->SetHiddenPrototype(true); |
10166 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 10236 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
10167 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 10237 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
10168 NULL, NULL, NULL, NULL, | 10238 NULL, NULL, NULL, NULL, |
10169 v8::External::New(&interceptor_call_count)); | 10239 v8::External::Wrap(&interceptor_call_count)); |
10170 LocalContext context; | 10240 LocalContext context; |
10171 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 10241 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
10172 GenerateSomeGarbage(); | 10242 GenerateSomeGarbage(); |
10173 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 10243 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
10174 v8::TryCatch try_catch; | 10244 v8::TryCatch try_catch; |
10175 CompileRun( | 10245 CompileRun( |
10176 "o.foo = 17;" | 10246 "o.foo = 17;" |
10177 "var receiver = {};" | 10247 "var receiver = {};" |
10178 "receiver.__proto__ = o;" | 10248 "receiver.__proto__ = o;" |
10179 "var result = 0;" | 10249 "var result = 0;" |
(...skipping 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12796 FACTORY->NewExternalStringFromAscii(&ascii_resource))); | 12866 FACTORY->NewExternalStringFromAscii(&ascii_resource))); |
12797 | 12867 |
12798 env->Global()->Set(v8_str("lhs"), lhs); | 12868 env->Global()->Set(v8_str("lhs"), lhs); |
12799 env->Global()->Set(v8_str("rhs"), rhs); | 12869 env->Global()->Set(v8_str("rhs"), rhs); |
12800 | 12870 |
12801 CompileRun( | 12871 CompileRun( |
12802 "var cons = lhs + rhs;" | 12872 "var cons = lhs + rhs;" |
12803 "var slice = lhs.substring(1, lhs.length - 1);" | 12873 "var slice = lhs.substring(1, lhs.length - 1);" |
12804 "var slice_on_cons = (lhs + rhs).substring(1, lhs.length *2 - 1);"); | 12874 "var slice_on_cons = (lhs + rhs).substring(1, lhs.length *2 - 1);"); |
12805 | 12875 |
12806 #ifndef ENABLE_LATIN_1 | |
12807 CHECK(!lhs->MayContainNonAscii()); | 12876 CHECK(!lhs->MayContainNonAscii()); |
12808 CHECK(!rhs->MayContainNonAscii()); | 12877 CHECK(!rhs->MayContainNonAscii()); |
12809 #endif | |
12810 | 12878 |
12811 MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource); | 12879 MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource); |
12812 MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource); | 12880 MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource); |
12813 | 12881 |
12814 // This should UTF-8 without flattening, since everything is ASCII. | 12882 // This should UTF-8 without flattening, since everything is ASCII. |
12815 Handle<String> cons = v8_compile("cons")->Run().As<String>(); | 12883 Handle<String> cons = v8_compile("cons")->Run().As<String>(); |
12816 CHECK_EQ(128, cons->Utf8Length()); | 12884 CHECK_EQ(128, cons->Utf8Length()); |
12817 int nchars = -1; | 12885 int nchars = -1; |
12818 CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars)); | 12886 CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars)); |
12819 CHECK_EQ(128, nchars); | 12887 CHECK_EQ(128, nchars); |
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15397 | 15465 |
15398 // Context-dependent context data creates reference from the compilation | 15466 // Context-dependent context data creates reference from the compilation |
15399 // cache to the global object. | 15467 // cache to the global object. |
15400 const char* source_simple = "1"; | 15468 const char* source_simple = "1"; |
15401 context = Context::New(); | 15469 context = Context::New(); |
15402 { | 15470 { |
15403 v8::HandleScope scope; | 15471 v8::HandleScope scope; |
15404 | 15472 |
15405 context->Enter(); | 15473 context->Enter(); |
15406 Local<v8::String> obj = v8::String::New(""); | 15474 Local<v8::String> obj = v8::String::New(""); |
15407 context->SetEmbedderData(0, obj); | 15475 context->SetData(obj); |
15408 CompileRun(source_simple); | 15476 CompileRun(source_simple); |
15409 context->Exit(); | 15477 context->Exit(); |
15410 } | 15478 } |
15411 context.Dispose(); | 15479 context.Dispose(); |
15412 v8::V8::ContextDisposedNotification(); | 15480 v8::V8::ContextDisposedNotification(); |
15413 for (gc_count = 1; gc_count < 10; gc_count++) { | 15481 for (gc_count = 1; gc_count < 10; gc_count++) { |
15414 other_context->Enter(); | 15482 other_context->Enter(); |
15415 CompileRun(source_simple); | 15483 CompileRun(source_simple); |
15416 other_context->Exit(); | 15484 other_context->Exit(); |
15417 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15485 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
(...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18121 | 18189 |
18122 i::Semaphore* sem_; | 18190 i::Semaphore* sem_; |
18123 volatile int sem_value_; | 18191 volatile int sem_value_; |
18124 }; | 18192 }; |
18125 | 18193 |
18126 | 18194 |
18127 THREADED_TEST(SemaphoreInterruption) { | 18195 THREADED_TEST(SemaphoreInterruption) { |
18128 ThreadInterruptTest().RunTest(); | 18196 ThreadInterruptTest().RunTest(); |
18129 } | 18197 } |
18130 #endif // WIN32 | 18198 #endif // WIN32 |
OLD | NEW |