Push version 2.4.2 to trunk.
Fixed GC crash bug.
Fixed stack corruption bug.
Fixed compilation for newer C++ compilers that found Operand(0) ambiguous.
git-svn-id: http://v8.googlecode.com/svn/trunk@5425 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 4b6fa9c..2b50db7 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -37,6 +37,7 @@
#include "top.h"
#include "utils.h"
#include "cctest.h"
+#include "parser.h"
static const bool kLogThreading = true;
@@ -3605,6 +3606,29 @@
}
+static const char* kNativeCallInExtensionSource =
+ "function call_runtime_last_index_of(x) {"
+ " return %StringLastIndexOf(x, 'bob', 10);"
+ "}";
+
+
+static const char* kNativeCallTest =
+ "call_runtime_last_index_of('bobbobboellebobboellebobbob');";
+
+// Test that a native runtime calls are supported in extensions.
+THREADED_TEST(NativeCallInExtensions) {
+ v8::HandleScope handle_scope;
+ v8::RegisterExtension(new Extension("nativecall",
+ kNativeCallInExtensionSource));
+ const char* extension_names[] = { "nativecall" };
+ v8::ExtensionConfiguration extensions(1, extension_names);
+ v8::Handle<Context> context = Context::New(&extensions);
+ Context::Scope lock(context);
+ v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run();
+ CHECK_EQ(result, v8::Integer::New(3));
+}
+
+
static void CheckDependencies(const char* name, const char* expected) {
v8::HandleScope handle_scope;
v8::ExtensionConfiguration config(1, &name);
@@ -8601,15 +8625,12 @@
v8::ScriptData::PreCompile(script, i::StrLength(script));
CHECK(!sd->HasError());
// ScriptDataImpl private implementation details
- const int kUnsignedSize = sizeof(unsigned);
- const int kHeaderSize = 4;
- const int kFunctionEntrySize = 5;
+ const int kHeaderSize = i::ScriptDataImpl::kHeaderSize;
+ const int kFunctionEntrySize = i::FunctionEntry::kSize;
const int kFunctionEntryStartOffset = 0;
const int kFunctionEntryEndOffset = 1;
unsigned* sd_data =
reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
- CHECK_EQ(sd->Length(),
- (kHeaderSize + 2 * kFunctionEntrySize) * kUnsignedSize);
// Overwrite function bar's end position with 0.
sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0;
diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc
index fee6624..7c669d3 100644
--- a/test/cctest/test-assembler-arm.cc
+++ b/test/cctest/test-assembler-arm.cc
@@ -91,7 +91,7 @@
Label L, C;
__ mov(r1, Operand(r0));
- __ mov(r0, Operand(0));
+ __ mov(r0, Operand(0, RelocInfo::NONE));
__ b(&C);
__ bind(&L);
@@ -99,7 +99,7 @@
__ sub(r1, r1, Operand(1));
__ bind(&C);
- __ teq(r1, Operand(0));
+ __ teq(r1, Operand(0, RelocInfo::NONE));
__ b(ne, &L);
__ mov(pc, Operand(lr));
@@ -135,7 +135,7 @@
__ sub(r1, r1, Operand(1));
__ bind(&C);
- __ teq(r1, Operand(0));
+ __ teq(r1, Operand(0, RelocInfo::NONE));
__ b(ne, &L);
__ mov(pc, Operand(lr));
diff --git a/test/cctest/test-assembler-mips.cc b/test/cctest/test-assembler-mips.cc
index 0a2310e..955562b 100644
--- a/test/cctest/test-assembler-mips.cc
+++ b/test/cctest/test-assembler-mips.cc
@@ -109,7 +109,7 @@
__ bind(&C);
__ xori(v1, a1, 0);
- __ Branch(ne, &L, v1, Operand(0));
+ __ Branch(ne, &L, v1, Operand(0, RelocInfo::NONE));
__ nop();
__ jr(ra);
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 9531b57..f5526ce 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -4591,6 +4591,18 @@
}
+// We match parts of the message to get source line.
+int GetSourceLineFromBreakEventMessage(char *message) {
+ const char* source_line = "\"sourceLine\":";
+ char* pos = strstr(message, source_line);
+ if (pos == NULL) {
+ return -1;
+ }
+ int res = -1;
+ res = StringToInt(pos + strlen(source_line));
+ return res;
+}
+
/* Test MessageQueues */
/* Tests the message queues that hold debugger commands and
* response messages to the debugger. Fills queues and makes
@@ -4870,6 +4882,9 @@
v8::String::Value json(message.GetJSON());
Utf16ToAscii(*json, json.length(), print_buffer);
if (IsBreakEventMessage(print_buffer)) {
+ // Check that we are inside the while loop.
+ int source_line = GetSourceLineFromBreakEventMessage(print_buffer);
+ CHECK(8 <= source_line && source_line <= 13);
threaded_debugging_barriers.barrier_2.Wait();
}
}
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index ed0c8b5..5ddd044 100755
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -31,6 +31,7 @@
#include "token.h"
#include "scanner.h"
+#include "parser.h"
#include "utils.h"
#include "execution.h"
@@ -148,7 +149,7 @@
NULL
};
- // Parser needs a stack limit.
+ // Parser/Scanner needs a stack limit.
int marker;
i::StackGuard::SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
@@ -160,3 +161,81 @@
delete data;
}
}
+
+
+class ScriptResource : public v8::String::ExternalAsciiStringResource {
+ public:
+ ScriptResource(const char* data, size_t length)
+ : data_(data), length_(length) { }
+
+ const char* data() const { return data_; }
+ size_t length() const { return length_; }
+
+ private:
+ const char* data_;
+ size_t length_;
+};
+
+
+TEST(Preparsing) {
+ v8::HandleScope handles;
+ v8::Persistent<v8::Context> context = v8::Context::New();
+ v8::Context::Scope context_scope(context);
+ int marker;
+ i::StackGuard::SetStackLimit(
+ reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
+
+ // Source containing functions that might be lazily compiled and all types
+ // of symbols (string, propertyName, regexp).
+ const char* source =
+ "var x = 42;"
+ "function foo(a) { return function nolazy(b) { return a + b; } }"
+ "function bar(a) { if (a) return function lazy(b) { return b; } }"
+ "var z = {'string': 'string literal', bareword: 'propertyName', "
+ " 42: 'number literal', for: 'keyword as propertyName', "
+ " f\\u006fr: 'keyword propertyname with escape'};"
+ "var v = /RegExp Literal/;"
+ "var w = /RegExp Literal\\u0020With Escape/gin;"
+ "var y = { get getter() { return 42; }, "
+ " set setter(v) { this.value = v; }};";
+ int source_length = strlen(source);
+ const char* error_source = "var x = y z;";
+ int error_source_length = strlen(error_source);
+
+ v8::ScriptData* preparse =
+ v8::ScriptData::PreCompile(source, source_length);
+ CHECK(!preparse->HasError());
+ bool lazy_flag = i::FLAG_lazy;
+ {
+ i::FLAG_lazy = true;
+ ScriptResource* resource = new ScriptResource(source, source_length);
+ v8::Local<v8::String> script_source = v8::String::NewExternal(resource);
+ v8::Script::Compile(script_source, NULL, preparse);
+ }
+
+ {
+ i::FLAG_lazy = false;
+
+ ScriptResource* resource = new ScriptResource(source, source_length);
+ v8::Local<v8::String> script_source = v8::String::NewExternal(resource);
+ v8::Script::New(script_source, NULL, preparse, v8::Local<v8::String>());
+ }
+ delete preparse;
+ i::FLAG_lazy = lazy_flag;
+
+ // Syntax error.
+ v8::ScriptData* error_preparse =
+ v8::ScriptData::PreCompile(error_source, error_source_length);
+ CHECK(error_preparse->HasError());
+ i::ScriptDataImpl *pre_impl =
+ reinterpret_cast<i::ScriptDataImpl*>(error_preparse);
+ i::Scanner::Location error_location =
+ pre_impl->MessageLocation();
+ // Error is at "z" in source, location 10..11.
+ CHECK_EQ(10, error_location.beg_pos);
+ CHECK_EQ(11, error_location.end_pos);
+ // Should not crash.
+ const char* message = pre_impl->BuildMessage();
+ i::Vector<const char*> args = pre_impl->BuildArgs();
+ CHECK_GT(strlen(message), 0);
+}
diff --git a/test/mjsunit/regress/regress-push-args-twice.js b/test/mjsunit/regress/regress-push-args-twice.js
new file mode 100644
index 0000000..faa6007
--- /dev/null
+++ b/test/mjsunit/regress/regress-push-args-twice.js
@@ -0,0 +1,37 @@
+// Copyright 2009 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.
+
+// Check that the ADD binary op stub correctly handles non-number arguments
+// passed on registers.
+
+try {
+ for (var key = 0; key != 10; key++) {
+ var x = 1 + undefined;
+ }
+} catch(e) {
+ fail("no exception", e);
+}
diff --git a/test/mjsunit/str-to-num.js b/test/mjsunit/str-to-num.js
index 20e2986..28e98d9 100644
--- a/test/mjsunit/str-to-num.js
+++ b/test/mjsunit/str-to-num.js
@@ -203,3 +203,7 @@
assertTrue(isNaN(toNumber("1e")), "1e");
assertTrue(isNaN(toNumber("1e ")), "1e_");
assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
+
+for (var i = 1; i < 12; i++) {
+ assertEquals(toNumber('1' + repeat('0', i)), Math.pow(10.0, i));
+}