OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); | 1420 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); |
1421 } | 1421 } |
1422 | 1422 |
1423 | 1423 |
1424 static const char* js_code_causing_out_of_memory = | 1424 static const char* js_code_causing_out_of_memory = |
1425 "var a = new Array(); while(true) a.push(a);"; | 1425 "var a = new Array(); while(true) a.push(a);"; |
1426 | 1426 |
1427 | 1427 |
1428 // These tests run for a long time and prevent us from running tests | 1428 // These tests run for a long time and prevent us from running tests |
1429 // that come after them so they cannot run in parallel. | 1429 // that come after them so they cannot run in parallel. |
1430 DISABLED_TEST(OutOfMemory) { | 1430 TEST(OutOfMemory) { |
1431 // It's not possible to read a snapshot into a heap with different dimensions. | 1431 // It's not possible to read a snapshot into a heap with different dimensions. |
1432 if (v8::internal::Snapshot::IsEnabled()) return; | 1432 if (v8::internal::Snapshot::IsEnabled()) return; |
1433 // Set heap limits. | 1433 // Set heap limits. |
1434 static const int K = 1024; | 1434 static const int K = 1024; |
1435 v8::ResourceConstraints constraints; | 1435 v8::ResourceConstraints constraints; |
1436 constraints.set_max_young_space_size(256 * K); | 1436 constraints.set_max_young_space_size(256 * K); |
1437 constraints.set_max_old_space_size(2 * K * K); | 1437 constraints.set_max_old_space_size(4 * K * K); |
1438 v8::SetResourceConstraints(&constraints); | 1438 v8::SetResourceConstraints(&constraints); |
1439 | 1439 |
1440 // Execute a script that causes out of memory. | 1440 // Execute a script that causes out of memory. |
1441 v8::HandleScope scope; | 1441 v8::HandleScope scope; |
1442 LocalContext context; | 1442 LocalContext context; |
1443 v8::V8::IgnoreOutOfMemoryException(); | 1443 v8::V8::IgnoreOutOfMemoryException(); |
1444 Local<Script> script = | 1444 Local<Script> script = |
1445 Script::Compile(String::New(js_code_causing_out_of_memory)); | 1445 Script::Compile(String::New(js_code_causing_out_of_memory)); |
1446 Local<Value> result = script->Run(); | 1446 Local<Value> result = script->Run(); |
1447 | 1447 |
(...skipping 13 matching lines...) Expand all Loading... |
1461 Local<Value> result = script->Run(); | 1461 Local<Value> result = script->Run(); |
1462 | 1462 |
1463 // Check for out of memory state. | 1463 // Check for out of memory state. |
1464 CHECK(result.IsEmpty()); | 1464 CHECK(result.IsEmpty()); |
1465 CHECK(context->HasOutOfMemoryException()); | 1465 CHECK(context->HasOutOfMemoryException()); |
1466 | 1466 |
1467 return result; | 1467 return result; |
1468 } | 1468 } |
1469 | 1469 |
1470 | 1470 |
1471 DISABLED_TEST(OutOfMemoryNested) { | 1471 TEST(OutOfMemoryNested) { |
1472 // It's not possible to read a snapshot into a heap with different dimensions. | 1472 // It's not possible to read a snapshot into a heap with different dimensions. |
1473 if (v8::internal::Snapshot::IsEnabled()) return; | 1473 if (v8::internal::Snapshot::IsEnabled()) return; |
1474 // Set heap limits. | 1474 // Set heap limits. |
1475 static const int K = 1024; | 1475 static const int K = 1024; |
1476 v8::ResourceConstraints constraints; | 1476 v8::ResourceConstraints constraints; |
1477 constraints.set_max_young_space_size(256 * K); | 1477 constraints.set_max_young_space_size(256 * K); |
1478 constraints.set_max_old_space_size(2 * K * K); | 1478 constraints.set_max_old_space_size(4 * K * K); |
1479 v8::SetResourceConstraints(&constraints); | 1479 v8::SetResourceConstraints(&constraints); |
1480 | 1480 |
1481 v8::HandleScope scope; | 1481 v8::HandleScope scope; |
1482 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 1482 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
1483 templ->Set(v8_str("ProvokeOutOfMemory"), | 1483 templ->Set(v8_str("ProvokeOutOfMemory"), |
1484 v8::FunctionTemplate::New(ProvokeOutOfMemory)); | 1484 v8::FunctionTemplate::New(ProvokeOutOfMemory)); |
1485 LocalContext context(0, templ); | 1485 LocalContext context(0, templ); |
1486 v8::V8::IgnoreOutOfMemoryException(); | 1486 v8::V8::IgnoreOutOfMemoryException(); |
1487 Local<Value> result = CompileRun( | 1487 Local<Value> result = CompileRun( |
1488 "var thrown = false;" | 1488 "var thrown = false;" |
(...skipping 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4898 v8::Handle<v8::Script> script0 = | 4898 v8::Handle<v8::Script> script0 = |
4899 v8::Script::Compile(source0, v8::String::New("test.js")); | 4899 v8::Script::Compile(source0, v8::String::New("test.js")); |
4900 v8::Handle<v8::Script> script1 = | 4900 v8::Handle<v8::Script> script1 = |
4901 v8::Script::Compile(source1, v8::String::New("test.js")); | 4901 v8::Script::Compile(source1, v8::String::New("test.js")); |
4902 v8::Handle<v8::Script> script2 = | 4902 v8::Handle<v8::Script> script2 = |
4903 v8::Script::Compile(source0); // different origin | 4903 v8::Script::Compile(source0); // different origin |
4904 CHECK_EQ(1234, script0->Run()->Int32Value()); | 4904 CHECK_EQ(1234, script0->Run()->Int32Value()); |
4905 CHECK_EQ(1234, script1->Run()->Int32Value()); | 4905 CHECK_EQ(1234, script1->Run()->Int32Value()); |
4906 CHECK_EQ(1234, script2->Run()->Int32Value()); | 4906 CHECK_EQ(1234, script2->Run()->Int32Value()); |
4907 } | 4907 } |
OLD | NEW |