| 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 19314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19325 Local<Value> v = CompileRun("22"); | 19325 Local<Value> v = CompileRun("22"); |
| 19326 CHECK(v->IsNumber()); | 19326 CHECK(v->IsNumber()); |
| 19327 CHECK_EQ(22, static_cast<int>(v->NumberValue())); | 19327 CHECK_EQ(22, static_cast<int>(v->NumberValue())); |
| 19328 } | 19328 } |
| 19329 isolate->Dispose(); | 19329 isolate->Dispose(); |
| 19330 } | 19330 } |
| 19331 | 19331 |
| 19332 class InitDefaultIsolateThread : public v8::internal::Thread { | 19332 class InitDefaultIsolateThread : public v8::internal::Thread { |
| 19333 public: | 19333 public: |
| 19334 enum TestCase { | 19334 enum TestCase { |
| 19335 IgnoreOOM, |
| 19335 SetResourceConstraints, | 19336 SetResourceConstraints, |
| 19336 SetFatalHandler, | 19337 SetFatalHandler, |
| 19337 SetCounterFunction, | 19338 SetCounterFunction, |
| 19338 SetCreateHistogramFunction, | 19339 SetCreateHistogramFunction, |
| 19339 SetAddHistogramSampleFunction | 19340 SetAddHistogramSampleFunction |
| 19340 }; | 19341 }; |
| 19341 | 19342 |
| 19342 explicit InitDefaultIsolateThread(TestCase testCase) | 19343 explicit InitDefaultIsolateThread(TestCase testCase) |
| 19343 : Thread("InitDefaultIsolateThread"), | 19344 : Thread("InitDefaultIsolateThread"), |
| 19344 testCase_(testCase), | 19345 testCase_(testCase), |
| 19345 result_(false) { } | 19346 result_(false) { } |
| 19346 | 19347 |
| 19347 void Run() { | 19348 void Run() { |
| 19348 v8::Isolate* isolate = v8::Isolate::New(); | 19349 v8::Isolate* isolate = v8::Isolate::New(); |
| 19349 isolate->Enter(); | 19350 isolate->Enter(); |
| 19350 switch (testCase_) { | 19351 switch (testCase_) { |
| 19351 case SetResourceConstraints: { | 19352 case IgnoreOOM: |
| 19352 static const int K = 1024; | 19353 v8::V8::IgnoreOutOfMemoryException(); |
| 19353 v8::ResourceConstraints constraints; | 19354 break; |
| 19354 constraints.set_max_young_space_size(256 * K); | |
| 19355 constraints.set_max_old_space_size(4 * K * K); | |
| 19356 v8::SetResourceConstraints(CcTest::isolate(), &constraints); | |
| 19357 break; | |
| 19358 } | |
| 19359 | 19355 |
| 19360 case SetFatalHandler: | 19356 case SetResourceConstraints: { |
| 19361 v8::V8::SetFatalErrorHandler(NULL); | 19357 static const int K = 1024; |
| 19362 break; | 19358 v8::ResourceConstraints constraints; |
| 19359 constraints.set_max_young_space_size(256 * K); |
| 19360 constraints.set_max_old_space_size(4 * K * K); |
| 19361 v8::SetResourceConstraints(CcTest::isolate(), &constraints); |
| 19362 break; |
| 19363 } |
| 19363 | 19364 |
| 19364 case SetCounterFunction: | 19365 case SetFatalHandler: |
| 19365 v8::V8::SetCounterFunction(NULL); | 19366 v8::V8::SetFatalErrorHandler(NULL); |
| 19366 break; | 19367 break; |
| 19367 | 19368 |
| 19368 case SetCreateHistogramFunction: | 19369 case SetCounterFunction: |
| 19369 v8::V8::SetCreateHistogramFunction(NULL); | 19370 v8::V8::SetCounterFunction(NULL); |
| 19370 break; | 19371 break; |
| 19371 | 19372 |
| 19372 case SetAddHistogramSampleFunction: | 19373 case SetCreateHistogramFunction: |
| 19373 v8::V8::SetAddHistogramSampleFunction(NULL); | 19374 v8::V8::SetCreateHistogramFunction(NULL); |
| 19374 break; | 19375 break; |
| 19376 |
| 19377 case SetAddHistogramSampleFunction: |
| 19378 v8::V8::SetAddHistogramSampleFunction(NULL); |
| 19379 break; |
| 19375 } | 19380 } |
| 19376 isolate->Exit(); | 19381 isolate->Exit(); |
| 19377 isolate->Dispose(); | 19382 isolate->Dispose(); |
| 19378 result_ = true; | 19383 result_ = true; |
| 19379 } | 19384 } |
| 19380 | 19385 |
| 19381 bool result() { return result_; } | 19386 bool result() { return result_; } |
| 19382 | 19387 |
| 19383 private: | 19388 private: |
| 19384 TestCase testCase_; | 19389 TestCase testCase_; |
| 19385 bool result_; | 19390 bool result_; |
| 19386 }; | 19391 }; |
| 19387 | 19392 |
| 19388 | 19393 |
| 19389 static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) { | 19394 static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) { |
| 19390 InitDefaultIsolateThread thread(testCase); | 19395 InitDefaultIsolateThread thread(testCase); |
| 19391 thread.Start(); | 19396 thread.Start(); |
| 19392 thread.Join(); | 19397 thread.Join(); |
| 19393 CHECK_EQ(thread.result(), true); | 19398 CHECK_EQ(thread.result(), true); |
| 19394 } | 19399 } |
| 19395 | 19400 |
| 19396 | 19401 |
| 19397 TEST(InitializeDefaultIsolateOnSecondaryThread1) { | 19402 TEST(InitializeDefaultIsolateOnSecondaryThread1) { |
| 19403 InitializeTestHelper(InitDefaultIsolateThread::IgnoreOOM); |
| 19404 } |
| 19405 |
| 19406 |
| 19407 TEST(InitializeDefaultIsolateOnSecondaryThread2) { |
| 19398 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); | 19408 InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); |
| 19399 } | 19409 } |
| 19400 | 19410 |
| 19401 | 19411 |
| 19402 TEST(InitializeDefaultIsolateOnSecondaryThread2) { | 19412 TEST(InitializeDefaultIsolateOnSecondaryThread3) { |
| 19403 InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler); | 19413 InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler); |
| 19404 } | 19414 } |
| 19405 | 19415 |
| 19406 | 19416 |
| 19407 TEST(InitializeDefaultIsolateOnSecondaryThread3) { | 19417 TEST(InitializeDefaultIsolateOnSecondaryThread4) { |
| 19408 InitializeTestHelper(InitDefaultIsolateThread::SetCounterFunction); | 19418 InitializeTestHelper(InitDefaultIsolateThread::SetCounterFunction); |
| 19409 } | 19419 } |
| 19410 | 19420 |
| 19411 | 19421 |
| 19412 TEST(InitializeDefaultIsolateOnSecondaryThread4) { | 19422 TEST(InitializeDefaultIsolateOnSecondaryThread5) { |
| 19413 InitializeTestHelper(InitDefaultIsolateThread::SetCreateHistogramFunction); | 19423 InitializeTestHelper(InitDefaultIsolateThread::SetCreateHistogramFunction); |
| 19414 } | 19424 } |
| 19415 | 19425 |
| 19416 | 19426 |
| 19417 TEST(InitializeDefaultIsolateOnSecondaryThread5) { | 19427 TEST(InitializeDefaultIsolateOnSecondaryThread6) { |
| 19418 InitializeTestHelper(InitDefaultIsolateThread::SetAddHistogramSampleFunction); | 19428 InitializeTestHelper(InitDefaultIsolateThread::SetAddHistogramSampleFunction); |
| 19419 } | 19429 } |
| 19420 | 19430 |
| 19421 | 19431 |
| 19422 TEST(StringCheckMultipleContexts) { | 19432 TEST(StringCheckMultipleContexts) { |
| 19423 const char* code = | 19433 const char* code = |
| 19424 "(function() { return \"a\".charAt(0); })()"; | 19434 "(function() { return \"a\".charAt(0); })()"; |
| 19425 | 19435 |
| 19426 { | 19436 { |
| 19427 // Run the code twice in the first context to initialize the call IC. | 19437 // Run the code twice in the first context to initialize the call IC. |
| (...skipping 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22307 "f.call(friend);"); | 22317 "f.call(friend);"); |
| 22308 CHECK_EQ(2, named_access_count); | 22318 CHECK_EQ(2, named_access_count); |
| 22309 | 22319 |
| 22310 // Test access using Object.setPrototypeOf reflective method. | 22320 // Test access using Object.setPrototypeOf reflective method. |
| 22311 named_access_count = 0; | 22321 named_access_count = 0; |
| 22312 CompileRun("Object.setPrototypeOf(friend, {});"); | 22322 CompileRun("Object.setPrototypeOf(friend, {});"); |
| 22313 CHECK_EQ(1, named_access_count); | 22323 CHECK_EQ(1, named_access_count); |
| 22314 CompileRun("Object.getPrototypeOf(friend);"); | 22324 CompileRun("Object.getPrototypeOf(friend);"); |
| 22315 CHECK_EQ(2, named_access_count); | 22325 CHECK_EQ(2, named_access_count); |
| 22316 } | 22326 } |
| OLD | NEW |