Revision: 6754
Author: [email protected]
Date: Fri Feb 11 06:26:56 2011
Log: Properly treat exceptions thrown while compiling.
BUG=v8:1132
TEST=test/mjsunit/regress/regress-1132.js
Review URL: http://codereview.chromium.org/6487021
http://code.google.com/p/v8/source/detail?r=6754
Added:
/branches/bleeding_edge/test/mjsunit/regress/regress-1132.js
Modified:
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/src/execution.cc
/branches/bleeding_edge/src/execution.h
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/test/mjsunit/mjsunit.status
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-1132.js Fri Feb 11
06:26:56 2011
@@ -0,0 +1,48 @@
+// Copyright 2011 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Test the case when exception is thrown from the parser when lazy
+// compiling a function.
+
+// Flags: --stack_size=32
+// NOTE: stack size constant above has been empirically chosen.
+// If the test starts to fail in Genesis, consider increasing this
constant.
+
+function test() {
+ try {
+ test(1, test(1));
+ } catch(e) {
+ assertFalse(delete e, "deleting catch variable");
+ assertEquals(42, e);
+ }
+}
+
+try {
+ test();
+ assertUnreachable();
+} catch (e) {
+}
=======================================
--- /branches/bleeding_edge/src/compiler.cc Fri Feb 11 04:25:41 2011
+++ /branches/bleeding_edge/src/compiler.cc Fri Feb 11 06:26:56 2011
@@ -288,6 +288,11 @@
HGraphBuilder builder(&oracle);
HPhase phase(HPhase::kTotal);
HGraph* graph = builder.CreateGraph(info);
+ if (Top::has_pending_exception()) {
+ info->SetCode(Handle<Code>::null());
+ return false;
+ }
+
if (graph != NULL && FLAG_build_lithium) {
Handle<Code> code = graph->Compile();
if (!code.is_null()) {
@@ -601,7 +606,9 @@
// Compile the code.
if (!MakeCode(info)) {
- Top::StackOverflow();
+ if (!Top::has_pending_exception()) {
+ Top::StackOverflow();
+ }
} else {
ASSERT(!info->code().is_null());
Handle<Code> code = info->code();
=======================================
--- /branches/bleeding_edge/src/execution.cc Wed Dec 15 07:25:53 2010
+++ /branches/bleeding_edge/src/execution.cc Fri Feb 11 06:26:56 2011
@@ -403,6 +403,7 @@
if (real_climit_ == kIllegalLimit) {
// Takes the address of the limit variable in order to find out where
// the top of stack is right now.
+ const uintptr_t kLimitSize = FLAG_stack_size * KB;
uintptr_t limit = reinterpret_cast<uintptr_t>(&limit) - kLimitSize;
ASSERT(reinterpret_cast<uintptr_t>(&limit) > kLimitSize);
real_jslimit_ = SimulatorStack::JsLimitFromCLimit(limit);
=======================================
--- /branches/bleeding_edge/src/execution.h Tue Dec 7 03:31:57 2010
+++ /branches/bleeding_edge/src/execution.h Fri Feb 11 06:26:56 2011
@@ -243,8 +243,6 @@
static void EnableInterrupts();
static void DisableInterrupts();
- static const uintptr_t kLimitSize = kPointerSize * 128 * KB;
-
#ifdef V8_TARGET_ARCH_X64
static const uintptr_t kInterruptLimit = V8_UINT64_C(0xfffffffffffffffe);
static const uintptr_t kIllegalLimit = V8_UINT64_C(0xfffffffffffffff8);
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Fri Feb 11 04:56:30 2011
+++ /branches/bleeding_edge/src/flag-definitions.h Fri Feb 11 06:26:56 2011
@@ -232,6 +232,10 @@
"in the queue")
DEFINE_bool(enable_liveedit, true, "enable liveedit experimental feature")
+// execution.cc
+DEFINE_int(stack_size, kPointerSize * 128,
+ "default size of stack region v8 is allowed to use (in
KkBytes)")
+
// frames.cc
DEFINE_int(max_stack_trace_source_length, 300,
"maximum length of function source code printed in a stack
trace.")
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Feb 11 05:20:06 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Fri Feb 11 06:26:56 2011
@@ -4033,6 +4033,9 @@
CompilationInfo inner_info(target);
if (!ParserApi::Parse(&inner_info) ||
!Scope::Analyze(&inner_info)) {
+ if (Top::has_pending_exception()) {
+ SetStackOverflow();
+ }
return false;
}
FunctionLiteral* function = inner_info.function();
=======================================
--- /branches/bleeding_edge/test/mjsunit/mjsunit.status Thu Feb 3 05:47:27
2011
+++ /branches/bleeding_edge/test/mjsunit/mjsunit.status Fri Feb 11 06:26:56
2011
@@ -105,6 +105,10 @@
regress/regress-3218915: SKIP
regress/regress-3247124: SKIP
+# Requires bigger stack size in the Genesis and if stack size is increased,
+# the test requires too much time to run. However, the problem test covers
+# should be platform-independent.
+regress/regress-1132: SKIP
##############################################################################
[ $arch == arm && $crankshaft ]
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev