Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: test/cctest/test-api.cc

Issue 559993005: Move configuration of ResourceConstraints to Isolate construction (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17870 matching lines...) Expand 10 before | Expand all | Expand 10 after
17881 // a very low address. 17881 // a very low address.
17882 if (answer > &size) return reinterpret_cast<uint32_t*>(sizeof(size)); 17882 if (answer > &size) return reinterpret_cast<uint32_t*>(sizeof(size));
17883 return answer; 17883 return answer;
17884 } 17884 }
17885 17885
17886 17886
17887 // We need at least 165kB for an x64 debug build with clang and ASAN. 17887 // We need at least 165kB for an x64 debug build with clang and ASAN.
17888 static const int stack_breathing_room = 256 * i::KB; 17888 static const int stack_breathing_room = 256 * i::KB;
17889 17889
17890 17890
17891 TEST(SetResourceConstraints) { 17891 TEST(SetStackLimit) {
17892 uint32_t* set_limit = ComputeStackLimit(stack_breathing_room); 17892 uint32_t* set_limit = ComputeStackLimit(stack_breathing_room);
17893 17893
17894 // Set stack limit. 17894 // Set stack limit.
17895 v8::ResourceConstraints constraints; 17895 CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit));
17896 constraints.set_stack_limit(set_limit);
17897 CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints));
17898 17896
17899 // Execute a script. 17897 // Execute a script.
17900 LocalContext env; 17898 LocalContext env;
17901 v8::HandleScope scope(env->GetIsolate()); 17899 v8::HandleScope scope(env->GetIsolate());
17902 Local<v8::FunctionTemplate> fun_templ = 17900 Local<v8::FunctionTemplate> fun_templ =
17903 v8::FunctionTemplate::New(env->GetIsolate(), GetStackLimitCallback); 17901 v8::FunctionTemplate::New(env->GetIsolate(), GetStackLimitCallback);
17904 Local<Function> fun = fun_templ->GetFunction(); 17902 Local<Function> fun = fun_templ->GetFunction();
17905 env->Global()->Set(v8_str("get_stack_limit"), fun); 17903 env->Global()->Set(v8_str("get_stack_limit"), fun);
17906 CompileRun("get_stack_limit();"); 17904 CompileRun("get_stack_limit();");
17907 17905
17908 CHECK(stack_limit == set_limit); 17906 CHECK(stack_limit == set_limit);
17909 } 17907 }
17910 17908
17911 17909
17912 TEST(SetResourceConstraintsInThread) { 17910 TEST(SetStackLimitInThread) {
17913 uint32_t* set_limit; 17911 uint32_t* set_limit;
17914 { 17912 {
17915 v8::Locker locker(CcTest::isolate()); 17913 v8::Locker locker(CcTest::isolate());
17916 set_limit = ComputeStackLimit(stack_breathing_room); 17914 set_limit = ComputeStackLimit(stack_breathing_room);
17917 17915
17918 // Set stack limit. 17916 // Set stack limit.
17919 v8::ResourceConstraints constraints; 17917 CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit));
17920 constraints.set_stack_limit(set_limit);
17921 CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints));
17922 17918
17923 // Execute a script. 17919 // Execute a script.
17924 v8::HandleScope scope(CcTest::isolate()); 17920 v8::HandleScope scope(CcTest::isolate());
17925 LocalContext env; 17921 LocalContext env;
17926 Local<v8::FunctionTemplate> fun_templ = 17922 Local<v8::FunctionTemplate> fun_templ =
17927 v8::FunctionTemplate::New(CcTest::isolate(), GetStackLimitCallback); 17923 v8::FunctionTemplate::New(CcTest::isolate(), GetStackLimitCallback);
17928 Local<Function> fun = fun_templ->GetFunction(); 17924 Local<Function> fun = fun_templ->GetFunction();
17929 env->Global()->Set(v8_str("get_stack_limit"), fun); 17925 env->Global()->Set(v8_str("get_stack_limit"), fun);
17930 CompileRun("get_stack_limit();"); 17926 CompileRun("get_stack_limit();");
17931 17927
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
19572 SetCreateHistogramFunction, 19568 SetCreateHistogramFunction,
19573 SetAddHistogramSampleFunction 19569 SetAddHistogramSampleFunction
19574 }; 19570 };
19575 19571
19576 explicit InitDefaultIsolateThread(TestCase testCase) 19572 explicit InitDefaultIsolateThread(TestCase testCase)
19577 : Thread(Options("InitDefaultIsolateThread")), 19573 : Thread(Options("InitDefaultIsolateThread")),
19578 testCase_(testCase), 19574 testCase_(testCase),
19579 result_(false) {} 19575 result_(false) {}
19580 19576
19581 void Run() { 19577 void Run() {
19582 v8::Isolate* isolate = v8::Isolate::New(); 19578 v8::Isolate::CreateParams create_params;
19579 switch (testCase_) {
19580 case SetResourceConstraints: {
19581 create_params.constraints.set_max_semi_space_size(1);
19582 create_params.constraints.set_max_old_space_size(4);
19583 break;
19584 }
19585 default:
19586 break;
19587 }
19588 v8::Isolate* isolate = v8::Isolate::New(create_params);
19583 isolate->Enter(); 19589 isolate->Enter();
19584 switch (testCase_) { 19590 switch (testCase_) {
19585 case SetResourceConstraints: { 19591 case SetResourceConstraints:
19586 v8::ResourceConstraints constraints; 19592 // Already handled in pre-Isolate-creation block.
19587 constraints.set_max_semi_space_size(1);
19588 constraints.set_max_old_space_size(4);
19589 v8::SetResourceConstraints(CcTest::isolate(), &constraints);
19590 break; 19593 break;
19591 }
19592 19594
19593 case SetFatalHandler: 19595 case SetFatalHandler:
19594 v8::V8::SetFatalErrorHandler(NULL); 19596 v8::V8::SetFatalErrorHandler(NULL);
19595 break; 19597 break;
19596 19598
19597 case SetCounterFunction: 19599 case SetCounterFunction:
19598 CcTest::isolate()->SetCounterFunction(NULL); 19600 CcTest::isolate()->SetCounterFunction(NULL);
19599 break; 19601 break;
19600 19602
19601 case SetCreateHistogramFunction: 19603 case SetCreateHistogramFunction:
(...skipping 3742 matching lines...) Expand 10 before | Expand all | Expand 10 after
23344 // TestSourceStream::GetMoreData won't block, so it's OK to just run the 23346 // TestSourceStream::GetMoreData won't block, so it's OK to just run the
23345 // task here in the main thread. 23347 // task here in the main thread.
23346 task->Run(); 23348 task->Run();
23347 delete task; 23349 delete task;
23348 23350
23349 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); 23351 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData();
23350 CHECK(cached_data != NULL); 23352 CHECK(cached_data != NULL);
23351 CHECK(cached_data->data != NULL); 23353 CHECK(cached_data->data != NULL);
23352 CHECK_GT(cached_data->length, 0); 23354 CHECK_GT(cached_data->length, 0);
23353 } 23355 }
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698