Commit 21f1ca58 authored by marja@chromium.org's avatar marja@chromium.org

Remove ScriptData::PreCompile which takes const char*.

The version taking a Handle should be used instead.

It's not used by Chromium and complicates the ongoing lexer work.

R=svenpanne@chromium.org
BUG=

Review URL: https://codereview.chromium.org/136413003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18556 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 854d0859
......@@ -942,16 +942,6 @@ class V8_EXPORT ScriptData { // NOLINT
public:
virtual ~ScriptData() { }
/**
* Pre-compiles the specified script (context-independent).
*
* \param input Pointer to UTF-8 script source code.
* \param length Length of UTF-8 script source code.
*/
static ScriptData* PreCompile(Isolate* isolate,
const char* input,
int length);
/**
* Pre-compiles the specified script (context-independent).
*
......
......@@ -1585,16 +1585,6 @@ void ObjectTemplate::SetInternalFieldCount(int value) {
// --- S c r i p t D a t a ---
ScriptData* ScriptData::PreCompile(v8::Isolate* isolate,
const char* input,
int length) {
i::Utf8ToUtf16CharacterStream stream(
reinterpret_cast<const unsigned char*>(input), length);
return i::PreParserApi::PreParse(
reinterpret_cast<i::Isolate*>(isolate), &stream);
}
ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
i::Handle<i::String> str = Utils::OpenHandle(*source);
i::Isolate* isolate = str->GetIsolate();
......
......@@ -14786,8 +14786,8 @@ TEST(PreCompile) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
const char* script = "function foo(a) { return a+1; }";
v8::ScriptData* sd =
v8::ScriptData::PreCompile(isolate, script, i::StrLength(script));
v8::ScriptData* sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
isolate, script, v8::String::kNormalString, i::StrLength(script)));
CHECK_NE(sd->Length(), 0);
CHECK_NE(sd->Data(), NULL);
CHECK(!sd->HasError());
......@@ -14799,8 +14799,8 @@ TEST(PreCompileWithError) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
const char* script = "function foo(a) { return 1 * * 2; }";
v8::ScriptData* sd =
v8::ScriptData::PreCompile(isolate, script, i::StrLength(script));
v8::ScriptData* sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
isolate, script, v8::String::kNormalString, i::StrLength(script)));
CHECK(sd->HasError());
delete sd;
}
......@@ -14810,8 +14810,8 @@ TEST(Regress31661) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
const char* script = " The Definintive Guide";
v8::ScriptData* sd =
v8::ScriptData::PreCompile(isolate, script, i::StrLength(script));
v8::ScriptData* sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
isolate, script, v8::String::kNormalString, i::StrLength(script)));
CHECK(sd->HasError());
delete sd;
}
......@@ -14822,8 +14822,8 @@ TEST(PreCompileSerialization) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
const char* script = "function foo(a) { return a+1; }";
v8::ScriptData* sd =
v8::ScriptData::PreCompile(isolate, script, i::StrLength(script));
v8::ScriptData* sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
isolate, script, v8::String::kNormalString, i::StrLength(script)));
// Serialize.
int serialized_data_length = sd->Length();
......@@ -14866,8 +14866,8 @@ TEST(PreCompileInvalidPreparseDataError) {
const char* script = "function foo(){ return 5;}\n"
"function bar(){ return 6 + 7;} foo();";
v8::ScriptData* sd =
v8::ScriptData::PreCompile(isolate, script, i::StrLength(script));
v8::ScriptData* sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
isolate, script, v8::String::kNormalString, i::StrLength(script)));
CHECK(!sd->HasError());
// ScriptDataImpl private implementation details
const int kHeaderSize = i::PreparseDataConstants::kHeaderSize;
......@@ -14893,7 +14893,8 @@ TEST(PreCompileInvalidPreparseDataError) {
// Overwrite function bar's start position with 200. The function entry
// will not be found when searching for it by position and we should fall
// back on eager compilation.
sd = v8::ScriptData::PreCompile(isolate, script, i::StrLength(script));
sd = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
isolate, script, v8::String::kNormalString, i::StrLength(script)));
sd_data = reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] =
200;
......@@ -14904,42 +14905,6 @@ TEST(PreCompileInvalidPreparseDataError) {
}
// Verifies that the Handle<String> and const char* versions of the API produce
// the same results (at least for one trivial case).
TEST(PreCompileAPIVariationsAreSame) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
const char* cstring = "function foo(a) { return a+1; }";
v8::ScriptData* sd_from_cstring =
v8::ScriptData::PreCompile(isolate, cstring, i::StrLength(cstring));
TestAsciiResource* resource = new TestAsciiResource(cstring);
v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile(
v8::String::NewExternal(isolate, resource));
v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile(
v8::String::NewFromUtf8(isolate, cstring));
CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length());
CHECK_EQ(0, memcmp(sd_from_cstring->Data(),
sd_from_external_string->Data(),
sd_from_cstring->Length()));
CHECK_EQ(sd_from_cstring->Length(), sd_from_string->Length());
CHECK_EQ(0, memcmp(sd_from_cstring->Data(),
sd_from_string->Data(),
sd_from_cstring->Length()));
delete sd_from_cstring;
delete sd_from_external_string;
delete sd_from_string;
}
// This tests that we do not allow dictionary load/call inline caches
// to use functions that have not yet been compiled. The potential
// problem of loading a function that has not yet been compiled can
......
......@@ -144,15 +144,20 @@ TEST(ScanHTMLEndComments) {
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
for (int i = 0; tests[i]; i++) {
v8::ScriptData* data =
v8::ScriptData::PreCompile(isolate, tests[i], i::StrLength(tests[i]));
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
isolate, tests[i], v8::String::kNormalString, i::StrLength(tests[i]));
v8::ScriptData* data = v8::ScriptData::PreCompile(source);
CHECK(data != NULL && !data->HasError());
delete data;
}
for (int i = 0; fail_tests[i]; i++) {
v8::ScriptData* data = v8::ScriptData::PreCompile(
isolate, fail_tests[i], i::StrLength(fail_tests[i]));
v8::Handle<v8::String> source =
v8::String::NewFromUtf8(isolate,
fail_tests[i],
v8::String::kNormalString,
i::StrLength(fail_tests[i]));
v8::ScriptData* data = v8::ScriptData::PreCompile(source);
CHECK(data == NULL || data->HasError());
delete data;
}
......@@ -199,8 +204,8 @@ TEST(Preparsing) {
const char* error_source = "var x = y z;";
int error_source_length = i::StrLength(error_source);
v8::ScriptData* preparse =
v8::ScriptData::PreCompile(isolate, source, source_length);
v8::ScriptData* preparse = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
isolate, source, v8::String::kNormalString, source_length));
CHECK(!preparse->HasError());
bool lazy_flag = i::FLAG_lazy;
{
......@@ -223,8 +228,11 @@ TEST(Preparsing) {
i::FLAG_lazy = lazy_flag;
// Syntax error.
v8::ScriptData* error_preparse =
v8::ScriptData::PreCompile(isolate, error_source, error_source_length);
v8::ScriptData* error_preparse = v8::ScriptData::PreCompile(
v8::String::NewFromUtf8(isolate,
error_source,
v8::String::kNormalString,
error_source_length));
CHECK(error_preparse->HasError());
i::ScriptDataImpl *pre_impl =
reinterpret_cast<i::ScriptDataImpl*>(error_preparse);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment