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 13074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13085 CHECK_EQ(result1, thread1.result()); | 13085 CHECK_EQ(result1, thread1.result()); |
13086 CHECK_EQ(result2, thread2.result()); | 13086 CHECK_EQ(result2, thread2.result()); |
13087 | 13087 |
13088 isolate1->Dispose(); | 13088 isolate1->Dispose(); |
13089 isolate2->Dispose(); | 13089 isolate2->Dispose(); |
13090 } | 13090 } |
13091 | 13091 |
13092 | 13092 |
13093 class InitDefaultIsolateThread : public v8::internal::Thread { | 13093 class InitDefaultIsolateThread : public v8::internal::Thread { |
13094 public: | 13094 public: |
13095 enum TestCase { IgnoreOOM, SetResourceConstraints, SetFatalHandler }; | 13095 enum TestCase { |
| 13096 IgnoreOOM, |
| 13097 SetResourceConstraints, |
| 13098 SetFatalHandler, |
| 13099 SetCounterFunction, |
| 13100 SetCreateHistogramFunction, |
| 13101 SetAddHistogramSampleFunction |
| 13102 }; |
13096 | 13103 |
13097 explicit InitDefaultIsolateThread(TestCase testCase) | 13104 explicit InitDefaultIsolateThread(TestCase testCase) |
13098 : Thread(NULL, "InitDefaultIsolateThread"), | 13105 : Thread(NULL, "InitDefaultIsolateThread"), |
13099 testCase_(testCase), | 13106 testCase_(testCase), |
13100 result_(false) { } | 13107 result_(false) { } |
13101 | 13108 |
13102 void Run() { | 13109 void Run() { |
13103 switch (testCase_) { | 13110 switch (testCase_) { |
13104 case IgnoreOOM: | 13111 case IgnoreOOM: |
13105 v8::V8::IgnoreOutOfMemoryException(); | 13112 v8::V8::IgnoreOutOfMemoryException(); |
13106 break; | 13113 break; |
13107 | 13114 |
13108 case SetResourceConstraints: { | 13115 case SetResourceConstraints: { |
13109 static const int K = 1024; | 13116 static const int K = 1024; |
13110 v8::ResourceConstraints constraints; | 13117 v8::ResourceConstraints constraints; |
13111 constraints.set_max_young_space_size(256 * K); | 13118 constraints.set_max_young_space_size(256 * K); |
13112 constraints.set_max_old_space_size(4 * K * K); | 13119 constraints.set_max_old_space_size(4 * K * K); |
13113 v8::SetResourceConstraints(&constraints); | 13120 v8::SetResourceConstraints(&constraints); |
13114 break; | 13121 break; |
13115 } | 13122 } |
13116 | 13123 |
13117 case SetFatalHandler: | 13124 case SetFatalHandler: |
13118 v8::V8::SetFatalErrorHandler(NULL); | 13125 v8::V8::SetFatalErrorHandler(NULL); |
13119 break; | 13126 break; |
| 13127 |
| 13128 case SetCounterFunction: |
| 13129 v8::V8::SetCounterFunction(NULL); |
| 13130 break; |
| 13131 |
| 13132 case SetCreateHistogramFunction: |
| 13133 v8::V8::SetCreateHistogramFunction(NULL); |
| 13134 break; |
| 13135 |
| 13136 case SetAddHistogramSampleFunction: |
| 13137 v8::V8::SetAddHistogramSampleFunction(NULL); |
| 13138 break; |
13120 } | 13139 } |
13121 result_ = true; | 13140 result_ = true; |
13122 } | 13141 } |
13123 | 13142 |
13124 bool result() { return result_; } | 13143 bool result() { return result_; } |
13125 | 13144 |
13126 private: | 13145 private: |
13127 TestCase testCase_; | 13146 TestCase testCase_; |
13128 bool result_; | 13147 bool result_; |
13129 }; | 13148 }; |
(...skipping 11 matching lines...) Expand all Loading... |
13141 } | 13160 } |
13142 | 13161 |
13143 TEST(InitializeDefaultIsolateOnSecondaryThread2) { | 13162 TEST(InitializeDefaultIsolateOnSecondaryThread2) { |
13144 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); | 13163 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); |
13145 } | 13164 } |
13146 | 13165 |
13147 TEST(InitializeDefaultIsolateOnSecondaryThread3) { | 13166 TEST(InitializeDefaultIsolateOnSecondaryThread3) { |
13148 InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler); | 13167 InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler); |
13149 } | 13168 } |
13150 | 13169 |
| 13170 TEST(InitializeDefaultIsolateOnSecondaryThread4) { |
| 13171 InitializeTestHelper(InitDefaultIsolateThread::SetCounterFunction); |
| 13172 } |
| 13173 |
| 13174 TEST(InitializeDefaultIsolateOnSecondaryThread5) { |
| 13175 InitializeTestHelper(InitDefaultIsolateThread::SetCreateHistogramFunction); |
| 13176 } |
| 13177 |
| 13178 TEST(InitializeDefaultIsolateOnSecondaryThread6) { |
| 13179 InitializeTestHelper(InitDefaultIsolateThread::SetAddHistogramSampleFunction); |
| 13180 } |
| 13181 |
13151 | 13182 |
13152 TEST(StringCheckMultipleContexts) { | 13183 TEST(StringCheckMultipleContexts) { |
13153 const char* code = | 13184 const char* code = |
13154 "(function() { return \"a\".charAt(0); })()"; | 13185 "(function() { return \"a\".charAt(0); })()"; |
13155 | 13186 |
13156 { | 13187 { |
13157 // Run the code twice in the first context to initialize the call IC. | 13188 // Run the code twice in the first context to initialize the call IC. |
13158 v8::HandleScope scope; | 13189 v8::HandleScope scope; |
13159 LocalContext context1; | 13190 LocalContext context1; |
13160 ExpectString(code, "a"); | 13191 ExpectString(code, "a"); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13475 v8::Handle<v8::Function> define_property = | 13506 v8::Handle<v8::Function> define_property = |
13476 CompileRun("(function() {" | 13507 CompileRun("(function() {" |
13477 " Object.defineProperty(" | 13508 " Object.defineProperty(" |
13478 " this," | 13509 " this," |
13479 " 1," | 13510 " 1," |
13480 " { configurable: true, enumerable: true, value: 3 });" | 13511 " { configurable: true, enumerable: true, value: 3 });" |
13481 "})").As<Function>(); | 13512 "})").As<Function>(); |
13482 context->DetachGlobal(); | 13513 context->DetachGlobal(); |
13483 define_property->Call(proxy, 0, NULL); | 13514 define_property->Call(proxy, 0, NULL); |
13484 } | 13515 } |
OLD | NEW |