OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 13163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13174 CHECK_EQ(result1, thread1.result()); | 13174 CHECK_EQ(result1, thread1.result()); |
13175 CHECK_EQ(result2, thread2.result()); | 13175 CHECK_EQ(result2, thread2.result()); |
13176 | 13176 |
13177 isolate1->Dispose(); | 13177 isolate1->Dispose(); |
13178 isolate2->Dispose(); | 13178 isolate2->Dispose(); |
13179 } | 13179 } |
13180 | 13180 |
13181 | 13181 |
13182 class InitDefaultIsolateThread : public v8::internal::Thread { | 13182 class InitDefaultIsolateThread : public v8::internal::Thread { |
13183 public: | 13183 public: |
13184 enum TestCase { IgnoreOOM, SetResourceConstraints, SetFatalHandler }; | 13184 enum TestCase { |
| 13185 IgnoreOOM, |
| 13186 SetResourceConstraints, |
| 13187 SetFatalHandler, |
| 13188 SetCounterFunction, |
| 13189 SetCreateHistogramFunction, |
| 13190 SetAddHistogramSampleFunction |
| 13191 }; |
13185 | 13192 |
13186 explicit InitDefaultIsolateThread(TestCase testCase) | 13193 explicit InitDefaultIsolateThread(TestCase testCase) |
13187 : Thread(NULL, "InitDefaultIsolateThread"), | 13194 : Thread(NULL, "InitDefaultIsolateThread"), |
13188 testCase_(testCase), | 13195 testCase_(testCase), |
13189 result_(false) { } | 13196 result_(false) { } |
13190 | 13197 |
13191 void Run() { | 13198 void Run() { |
13192 switch (testCase_) { | 13199 switch (testCase_) { |
13193 case IgnoreOOM: | 13200 case IgnoreOOM: |
13194 v8::V8::IgnoreOutOfMemoryException(); | 13201 v8::V8::IgnoreOutOfMemoryException(); |
13195 break; | 13202 break; |
13196 | 13203 |
13197 case SetResourceConstraints: { | 13204 case SetResourceConstraints: { |
13198 static const int K = 1024; | 13205 static const int K = 1024; |
13199 v8::ResourceConstraints constraints; | 13206 v8::ResourceConstraints constraints; |
13200 constraints.set_max_young_space_size(256 * K); | 13207 constraints.set_max_young_space_size(256 * K); |
13201 constraints.set_max_old_space_size(4 * K * K); | 13208 constraints.set_max_old_space_size(4 * K * K); |
13202 v8::SetResourceConstraints(&constraints); | 13209 v8::SetResourceConstraints(&constraints); |
13203 break; | 13210 break; |
13204 } | 13211 } |
13205 | 13212 |
13206 case SetFatalHandler: | 13213 case SetFatalHandler: |
13207 v8::V8::SetFatalErrorHandler(NULL); | 13214 v8::V8::SetFatalErrorHandler(NULL); |
13208 break; | 13215 break; |
| 13216 |
| 13217 case SetCounterFunction: |
| 13218 v8::V8::SetCounterFunction(NULL); |
| 13219 break; |
| 13220 |
| 13221 case SetCreateHistogramFunction: |
| 13222 v8::V8::SetCreateHistogramFunction(NULL); |
| 13223 break; |
| 13224 |
| 13225 case SetAddHistogramSampleFunction: |
| 13226 v8::V8::SetAddHistogramSampleFunction(NULL); |
| 13227 break; |
13209 } | 13228 } |
13210 result_ = true; | 13229 result_ = true; |
13211 } | 13230 } |
13212 | 13231 |
13213 bool result() { return result_; } | 13232 bool result() { return result_; } |
13214 | 13233 |
13215 private: | 13234 private: |
13216 TestCase testCase_; | 13235 TestCase testCase_; |
13217 bool result_; | 13236 bool result_; |
13218 }; | 13237 }; |
(...skipping 11 matching lines...) Expand all Loading... |
13230 } | 13249 } |
13231 | 13250 |
13232 TEST(InitializeDefaultIsolateOnSecondaryThread2) { | 13251 TEST(InitializeDefaultIsolateOnSecondaryThread2) { |
13233 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); | 13252 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); |
13234 } | 13253 } |
13235 | 13254 |
13236 TEST(InitializeDefaultIsolateOnSecondaryThread3) { | 13255 TEST(InitializeDefaultIsolateOnSecondaryThread3) { |
13237 InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler); | 13256 InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler); |
13238 } | 13257 } |
13239 | 13258 |
| 13259 TEST(InitializeDefaultIsolateOnSecondaryThread4) { |
| 13260 InitializeTestHelper(InitDefaultIsolateThread::SetCounterFunction); |
| 13261 } |
| 13262 |
| 13263 TEST(InitializeDefaultIsolateOnSecondaryThread5) { |
| 13264 InitializeTestHelper(InitDefaultIsolateThread::SetCreateHistogramFunction); |
| 13265 } |
| 13266 |
| 13267 TEST(InitializeDefaultIsolateOnSecondaryThread6) { |
| 13268 InitializeTestHelper(InitDefaultIsolateThread::SetAddHistogramSampleFunction); |
| 13269 } |
| 13270 |
13240 | 13271 |
13241 TEST(StringCheckMultipleContexts) { | 13272 TEST(StringCheckMultipleContexts) { |
13242 const char* code = | 13273 const char* code = |
13243 "(function() { return \"a\".charAt(0); })()"; | 13274 "(function() { return \"a\".charAt(0); })()"; |
13244 | 13275 |
13245 { | 13276 { |
13246 // Run the code twice in the first context to initialize the call IC. | 13277 // Run the code twice in the first context to initialize the call IC. |
13247 v8::HandleScope scope; | 13278 v8::HandleScope scope; |
13248 LocalContext context1; | 13279 LocalContext context1; |
13249 ExpectString(code, "a"); | 13280 ExpectString(code, "a"); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13564 v8::Handle<v8::Function> define_property = | 13595 v8::Handle<v8::Function> define_property = |
13565 CompileRun("(function() {" | 13596 CompileRun("(function() {" |
13566 " Object.defineProperty(" | 13597 " Object.defineProperty(" |
13567 " this," | 13598 " this," |
13568 " 1," | 13599 " 1," |
13569 " { configurable: true, enumerable: true, value: 3 });" | 13600 " { configurable: true, enumerable: true, value: 3 });" |
13570 "})").As<Function>(); | 13601 "})").As<Function>(); |
13571 context->DetachGlobal(); | 13602 context->DetachGlobal(); |
13572 define_property->Call(proxy, 0, NULL); | 13603 define_property->Call(proxy, 0, NULL); |
13573 } | 13604 } |
OLD | NEW |