Revision: 23964
Author: [email protected]
Date: Tue Sep 16 09:15:02 2014 UTC
Log: Move configuration of ResourceConstraints to Isolate construction
We can only set resource constraints before the isolate is initialized.
Since in the future, we want to initialize isolates at construction
time, we need to set constraints there.
It's possible to later modify the stack limit, so introduce an
Isolate::SetStackLimit method for that.
The SetResourceConstraints method will be deprecated. Users should pass
ResourceConstraints to Isolate::New, and use Isolate::SetStackLimit to
later modify the stack limit.
BUG=none
[email protected]
LOG=y
Review URL: https://codereview.chromium.org/559993005
https://code.google.com/p/v8/source/detail?r=23964
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/d8.cc
/branches/bleeding_edge/test/cctest/test-api.cc
/branches/bleeding_edge/test/cctest/test-strings.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Mon Sep 15 11:17:00 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Tue Sep 16 09:15:02 2014 UTC
@@ -4101,6 +4101,9 @@
/**
* Sets the given ResourceConstraints on the given Isolate.
+ *
+ * Deprecated, will be removed. Pass constraints via Isolate::New or modify
+ * the stack limit via Isolate::SetStackLimit.
*/
bool V8_EXPORT SetResourceConstraints(Isolate* isolate,
ResourceConstraints* constraints);
@@ -4371,6 +4374,11 @@
* notified each time code is added, moved or removed.
*/
JitCodeEventHandler code_event_handler;
+
+ /**
+ * ResourceConstraints to use for the new Isolate.
+ */
+ ResourceConstraints constraints;
};
@@ -4817,6 +4825,17 @@
void SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler);
+ /**
+ * Modifies the stack limit for this Isolate.
+ *
+ * \param stack_limit An address beyond which the Vm's stack may not
grow.
+ *
+ * \note If you are using threads then you should hold the V8::Locker
lock
+ * while setting the stack limit and you must set a non-default stack
+ * limit separately for each thread.
+ */
+ void SetStackLimit(uintptr_t stack_limit);
+
private:
template<class K, class V, class Traits> friend class PersistentValueMap;
=======================================
--- /branches/bleeding_edge/src/api.cc Mon Sep 15 11:17:00 2014 UTC
+++ /branches/bleeding_edge/src/api.cc Tue Sep 16 09:15:02 2014 UTC
@@ -6664,6 +6664,7 @@
Isolate* Isolate::New(const Isolate::CreateParams& params) {
i::Isolate* isolate = new i::Isolate();
+ Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
if (params.entry_hook) {
isolate->set_function_entry_hook(params.entry_hook);
}
@@ -6672,7 +6673,9 @@
isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault,
params.code_event_handler);
}
- return reinterpret_cast<Isolate*>(isolate);
+ SetResourceConstraints(v8_isolate,
+
const_cast<ResourceConstraints*>(¶ms.constraints));
+ return v8_isolate;
}
@@ -6887,6 +6890,13 @@
isolate->InitializeLoggingAndCounters();
isolate->logger()->SetCodeEventHandler(options, event_handler);
}
+
+
+void v8::Isolate::SetStackLimit(uintptr_t stack_limit) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ CHECK(stack_limit);
+ isolate->stack_guard()->SetStackLimit(stack_limit);
+}
String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
=======================================
--- /branches/bleeding_edge/src/d8.cc Tue Sep 16 09:14:11 2014 UTC
+++ /branches/bleeding_edge/src/d8.cc Tue Sep 16 09:15:02 2014 UTC
@@ -1621,14 +1621,13 @@
#ifdef ENABLE_VTUNE_JIT_INTERFACE
vTune::InitializeVtuneForV8(create_params);
#endif
- Isolate* isolate = Isolate::New(create_params);
#ifndef V8_SHARED
- v8::ResourceConstraints constraints;
- constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
- base::SysInfo::AmountOfVirtualMemory(),
- base::SysInfo::NumberOfProcessors());
- v8::SetResourceConstraints(isolate, &constraints);
+ create_params.constraints.ConfigureDefaults(
+ base::SysInfo::AmountOfPhysicalMemory(),
+ base::SysInfo::AmountOfVirtualMemory(),
+ base::SysInfo::NumberOfProcessors());
#endif
+ Isolate* isolate = Isolate::New(create_params);
DumbLineEditor dumb_line_editor(isolate);
{
Isolate::Scope scope(isolate);
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Mon Sep 15 11:17:00
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-api.cc Tue Sep 16 09:15:02
2014 UTC
@@ -17888,13 +17888,11 @@
static const int stack_breathing_room = 256 * i::KB;
-TEST(SetResourceConstraints) {
+TEST(SetStackLimit) {
uint32_t* set_limit = ComputeStackLimit(stack_breathing_room);
// Set stack limit.
- v8::ResourceConstraints constraints;
- constraints.set_stack_limit(set_limit);
- CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints));
+ CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit));
// Execute a script.
LocalContext env;
@@ -17909,16 +17907,14 @@
}
-TEST(SetResourceConstraintsInThread) {
+TEST(SetStackLimitInThread) {
uint32_t* set_limit;
{
v8::Locker locker(CcTest::isolate());
set_limit = ComputeStackLimit(stack_breathing_room);
// Set stack limit.
- v8::ResourceConstraints constraints;
- constraints.set_stack_limit(set_limit);
- CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints));
+
CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit));
// Execute a script.
v8::HandleScope scope(CcTest::isolate());
@@ -19579,16 +19575,22 @@
result_(false) {}
void Run() {
- v8::Isolate* isolate = v8::Isolate::New();
- isolate->Enter();
+ v8::Isolate::CreateParams create_params;
switch (testCase_) {
case SetResourceConstraints: {
- v8::ResourceConstraints constraints;
- constraints.set_max_semi_space_size(1);
- constraints.set_max_old_space_size(4);
- v8::SetResourceConstraints(CcTest::isolate(), &constraints);
+ create_params.constraints.set_max_semi_space_size(1);
+ create_params.constraints.set_max_old_space_size(4);
break;
}
+ default:
+ break;
+ }
+ v8::Isolate* isolate = v8::Isolate::New(create_params);
+ isolate->Enter();
+ switch (testCase_) {
+ case SetResourceConstraints:
+ // Already handled in pre-Isolate-creation block.
+ break;
case SetFatalHandler:
v8::V8::SetFatalErrorHandler(NULL);
=======================================
--- /branches/bleeding_edge/test/cctest/test-strings.cc Wed Sep 10 12:38:12
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-strings.cc Tue Sep 16 09:15:02
2014 UTC
@@ -1209,28 +1209,34 @@
}
-TEST(OneByteArrayJoin) {
+UNINITIALIZED_TEST(OneByteArrayJoin) {
+ v8::Isolate::CreateParams create_params;
// Set heap limits.
- v8::ResourceConstraints constraints;
- constraints.set_max_semi_space_size(1);
- constraints.set_max_old_space_size(4);
- v8::SetResourceConstraints(CcTest::isolate(), &constraints);
+ create_params.constraints.set_max_semi_space_size(1);
+ create_params.constraints.set_max_old_space_size(4);
+ v8::Isolate* isolate = v8::Isolate::New(create_params);
+ isolate->Enter();
- // String s is made of 2^17 = 131072 'c' characters and a is an array
- // starting with 'bad', followed by 2^14 times the string s. That means
the
- // total length of the concatenated strings is 2^31 + 3. So on 32bit
systems
- // summing the lengths of the strings (as Smis) overflows and wraps.
- LocalContext context;
- v8::HandleScope scope(CcTest::isolate());
- v8::TryCatch try_catch;
- CHECK(CompileRun(
- "var two_14 = Math.pow(2, 14);"
- "var two_17 = Math.pow(2, 17);"
- "var s = Array(two_17 + 1).join('c');"
- "var a = ['bad'];"
- "for (var i = 1; i <= two_14; i++) a.push(s);"
- "a.join("");").IsEmpty());
- CHECK(try_catch.HasCaught());
+ {
+ // String s is made of 2^17 = 131072 'c' characters and a is an array
+ // starting with 'bad', followed by 2^14 times the string s. That
means the
+ // total length of the concatenated strings is 2^31 + 3. So on 32bit
systems
+ // summing the lengths of the strings (as Smis) overflows and wraps.
+ LocalContext context(isolate);
+ v8::HandleScope scope(isolate);
+ v8::TryCatch try_catch;
+ CHECK(CompileRun(
+ "var two_14 = Math.pow(2, 14);"
+ "var two_17 = Math.pow(2, 17);"
+ "var s = Array(two_17 + 1).join('c');"
+ "var a = ['bad'];"
+ "for (var i = 1; i <= two_14; i++) a.push(s);"
+ "a.join("
+ ");").IsEmpty());
+ CHECK(try_catch.HasCaught());
+ }
+ isolate->Exit();
+ isolate->Dispose();
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.