| 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 11004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11015 Local<Function> function = function_template->GetFunction(); | 11015 Local<Function> function = function_template->GetFunction(); |
| 11016 Local<Object> instance = function; | 11016 Local<Object> instance = function; |
| 11017 v8::TryCatch try_catch; | 11017 v8::TryCatch try_catch; |
| 11018 | 11018 |
| 11019 CHECK(instance->IsCallable()); | 11019 CHECK(instance->IsCallable()); |
| 11020 CHECK(!try_catch.HasCaught()); | 11020 CHECK(!try_catch.HasCaught()); |
| 11021 } | 11021 } |
| 11022 } | 11022 } |
| 11023 | 11023 |
| 11024 | 11024 |
| 11025 static int CountHandles() { | 11025 static int Recurse(v8::Isolate* isolate, int depth, int iterations) { |
| 11026 return v8::HandleScope::NumberOfHandles(); | 11026 v8::HandleScope scope(isolate); |
| 11027 } | 11027 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate); |
| 11028 | |
| 11029 | |
| 11030 static int Recurse(int depth, int iterations) { | |
| 11031 v8::HandleScope scope(CcTest::isolate()); | |
| 11032 if (depth == 0) return CountHandles(); | |
| 11033 for (int i = 0; i < iterations; i++) { | 11028 for (int i = 0; i < iterations; i++) { |
| 11034 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); | 11029 Local<v8::Number> n(v8::Integer::New(isolate, 42)); |
| 11035 } | 11030 } |
| 11036 return Recurse(depth - 1, iterations); | 11031 return Recurse(isolate, depth - 1, iterations); |
| 11037 } | 11032 } |
| 11038 | 11033 |
| 11039 | 11034 |
| 11040 THREADED_TEST(HandleIteration) { | 11035 THREADED_TEST(HandleIteration) { |
| 11041 static const int kIterations = 500; | 11036 static const int kIterations = 500; |
| 11042 static const int kNesting = 200; | 11037 static const int kNesting = 200; |
| 11043 CHECK_EQ(0, CountHandles()); | 11038 LocalContext context; |
| 11039 v8::Isolate* isolate = context->GetIsolate(); |
| 11040 v8::HandleScope scope0(isolate); |
| 11041 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate)); |
| 11044 { | 11042 { |
| 11045 v8::HandleScope scope1(CcTest::isolate()); | 11043 v8::HandleScope scope1(isolate); |
| 11046 CHECK_EQ(0, CountHandles()); | 11044 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate)); |
| 11047 for (int i = 0; i < kIterations; i++) { | 11045 for (int i = 0; i < kIterations; i++) { |
| 11048 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); | 11046 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
| 11049 CHECK_EQ(i + 1, CountHandles()); | 11047 CHECK_EQ(i + 1, v8::HandleScope::NumberOfHandles(isolate)); |
| 11050 } | 11048 } |
| 11051 | 11049 |
| 11052 CHECK_EQ(kIterations, CountHandles()); | 11050 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate)); |
| 11053 { | 11051 { |
| 11054 v8::HandleScope scope2(CcTest::isolate()); | 11052 v8::HandleScope scope2(CcTest::isolate()); |
| 11055 for (int j = 0; j < kIterations; j++) { | 11053 for (int j = 0; j < kIterations; j++) { |
| 11056 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); | 11054 Local<v8::Number> n(v8::Integer::New(CcTest::isolate(), 42)); |
| 11057 CHECK_EQ(j + 1 + kIterations, CountHandles()); | 11055 CHECK_EQ(j + 1 + kIterations, |
| 11056 v8::HandleScope::NumberOfHandles(isolate)); |
| 11058 } | 11057 } |
| 11059 } | 11058 } |
| 11060 CHECK_EQ(kIterations, CountHandles()); | 11059 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate)); |
| 11061 } | 11060 } |
| 11062 CHECK_EQ(0, CountHandles()); | 11061 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate)); |
| 11063 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); | 11062 CHECK_EQ(kNesting * kIterations, Recurse(isolate, kNesting, kIterations)); |
| 11064 } | 11063 } |
| 11065 | 11064 |
| 11066 | 11065 |
| 11067 static void InterceptorHasOwnPropertyGetter( | 11066 static void InterceptorHasOwnPropertyGetter( |
| 11068 Local<String> name, | 11067 Local<String> name, |
| 11069 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11068 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 11070 ApiTestFuzzer::Fuzz(); | 11069 ApiTestFuzzer::Fuzz(); |
| 11071 } | 11070 } |
| 11072 | 11071 |
| 11073 | 11072 |
| (...skipping 10575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21649 } | 21648 } |
| 21650 for (int i = 0; i < runs; i++) { | 21649 for (int i = 0; i < runs; i++) { |
| 21651 Local<String> expected; | 21650 Local<String> expected; |
| 21652 if (i != 0) { | 21651 if (i != 0) { |
| 21653 CHECK_EQ(v8_str("escape value"), values[i]); | 21652 CHECK_EQ(v8_str("escape value"), values[i]); |
| 21654 } else { | 21653 } else { |
| 21655 CHECK(values[i].IsEmpty()); | 21654 CHECK(values[i].IsEmpty()); |
| 21656 } | 21655 } |
| 21657 } | 21656 } |
| 21658 } | 21657 } |
| OLD | NEW |