Commit 0e830ad0 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Do not embed array objects in unoptimized code.

R=verwaest@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#25019}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25019 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 75ac4392
......@@ -159,9 +159,6 @@ bool AstValue::BooleanValue() const {
return DoubleToBoolean(number_);
case SMI:
return smi_ != 0;
case STRING_ARRAY:
UNREACHABLE();
break;
case BOOLEAN:
return bool_;
case NULL_TYPE:
......@@ -202,22 +199,6 @@ void AstValue::Internalize(Isolate* isolate) {
value_ = isolate->factory()->false_value();
}
break;
case STRING_ARRAY: {
DCHECK(strings_ != NULL);
Factory* factory = isolate->factory();
int len = strings_->length();
Handle<FixedArray> elements = factory->NewFixedArray(len, TENURED);
for (int i = 0; i < len; i++) {
const AstRawString* string = (*strings_)[i];
Handle<Object> element = string->string();
// Strings are already internalized.
DCHECK(!element.is_null());
elements->set(i, *element);
}
value_ =
factory->NewJSArrayWithElements(elements, FAST_ELEMENTS, TENURED);
break;
}
case NULL_TYPE:
value_ = isolate->factory()->null_value();
break;
......@@ -350,17 +331,6 @@ const AstValue* AstValueFactory::NewBoolean(bool b) {
}
const AstValue* AstValueFactory::NewStringList(
ZoneList<const AstRawString*>* strings) {
AstValue* value = new (zone_) AstValue(strings);
if (isolate_) {
value->Internalize(isolate_);
}
values_.Add(value);
return value;
}
const AstValue* AstValueFactory::NewNull() {
GENERATE_VALUE_GETTER(null_value_, AstValue::NULL_TYPE);
}
......
......@@ -194,7 +194,6 @@ class AstValue : public ZoneObject {
NUMBER,
SMI,
BOOLEAN,
STRING_ARRAY,
NULL_TYPE,
UNDEFINED,
THE_HOLE
......@@ -213,10 +212,6 @@ class AstValue : public ZoneObject {
explicit AstValue(bool b) : type_(BOOLEAN) { bool_ = b; }
explicit AstValue(ZoneList<const AstRawString*>* s) : type_(STRING_ARRAY) {
strings_ = s;
}
explicit AstValue(Type t) : type_(t) {
DCHECK(t == NULL_TYPE || t == UNDEFINED || t == THE_HOLE);
}
......@@ -239,33 +234,33 @@ class AstValue : public ZoneObject {
// For generating constants.
#define STRING_CONSTANTS(F) \
F(anonymous_function, "(anonymous function)") \
F(arguments, "arguments") \
F(constructor, "constructor") \
F(done, "done") \
F(dot, ".") \
F(dot_for, ".for") \
F(dot_generator, ".generator") \
F(dot_generator_object, ".generator_object") \
F(dot_iterator, ".iterator") \
F(dot_module, ".module") \
F(dot_result, ".result") \
F(empty, "") \
F(eval, "eval") \
F(initialize_const_global, "initializeConstGlobal") \
F(initialize_var_global, "initializeVarGlobal") \
F(make_reference_error, "MakeReferenceError") \
F(make_syntax_error, "MakeSyntaxError") \
F(make_type_error, "MakeTypeError") \
F(module, "module") \
F(native, "native") \
F(next, "next") \
F(proto, "__proto__") \
F(prototype, "prototype") \
F(this, "this") \
F(use_asm, "use asm") \
F(use_strict, "use strict") \
#define STRING_CONSTANTS(F) \
F(anonymous_function, "(anonymous function)") \
F(arguments, "arguments") \
F(constructor, "constructor") \
F(done, "done") \
F(dot, ".") \
F(dot_for, ".for") \
F(dot_generator, ".generator") \
F(dot_generator_object, ".generator_object") \
F(dot_iterator, ".iterator") \
F(dot_module, ".module") \
F(dot_result, ".result") \
F(empty, "") \
F(eval, "eval") \
F(initialize_const_global, "initializeConstGlobal") \
F(initialize_var_global, "initializeVarGlobal") \
F(make_reference_error, "MakeReferenceErrorEmbedded") \
F(make_syntax_error, "MakeSyntaxErrorEmbedded") \
F(make_type_error, "MakeTypeErrorEmbedded") \
F(module, "module") \
F(native, "native") \
F(next, "next") \
F(proto, "__proto__") \
F(prototype, "prototype") \
F(this, "this") \
F(use_asm, "use asm") \
F(use_strict, "use strict") \
F(value, "value")
#define OTHER_CONSTANTS(F) \
......
......@@ -3415,13 +3415,6 @@ class AstNodeFactory FINAL BASE_EMBEDDED {
VISIT_AND_RETURN(Literal, lit)
}
Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings,
int pos) {
Literal* lit = new (zone_)
Literal(zone_, ast_value_factory_->NewStringList(strings), pos);
VISIT_AND_RETURN(Literal, lit)
}
Literal* NewNullLiteral(int pos) {
Literal* lit =
new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos);
......
......@@ -367,6 +367,23 @@ function MakeError(type, args) {
return MakeGenericError($Error, type, args);
}
// The embedded versions are called from unoptimized code, with embedded
// arguments. Those arguments cannot be arrays, which are context-dependent.
function MakeTypeErrorEmbedded(type, arg) {
return MakeGenericError($TypeError, type, [arg]);
}
function MakeSyntaxErrorEmbedded(type, arg) {
return MakeGenericError($SyntaxError, type, [arg]);
}
function MakeReferenceErrorEmbedded(type, arg) {
return MakeGenericError($ReferenceError, type, [arg]);
}
/**
* Find a line number given a specific source position.
* @param {number} position The source position.
......
......@@ -519,7 +519,7 @@ Expression* ParserTraits::BuildUnaryExpression(
Expression* ParserTraits::NewThrowReferenceError(const char* message, int pos) {
return NewThrowError(
parser_->ast_value_factory()->make_reference_error_string(), message,
NULL, pos);
parser_->ast_value_factory()->empty_string(), pos);
}
......@@ -541,17 +541,11 @@ Expression* ParserTraits::NewThrowError(
const AstRawString* constructor, const char* message,
const AstRawString* arg, int pos) {
Zone* zone = parser_->zone();
int argc = arg != NULL ? 1 : 0;
const AstRawString* type =
parser_->ast_value_factory()->GetOneByteString(message);
ZoneList<const AstRawString*>* array =
new (zone) ZoneList<const AstRawString*>(argc, zone);
if (arg != NULL) {
array->Add(arg, zone);
}
ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone);
args->Add(parser_->factory()->NewStringLiteral(type, pos), zone);
args->Add(parser_->factory()->NewStringListLiteral(array, pos), zone);
args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone);
CallRuntime* call_constructor =
parser_->factory()->NewCallRuntime(constructor, NULL, args, pos);
return parser_->factory()->NewThrow(call_constructor, pos);
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// --serialize-toplevel --cache=code
var caught = false;
try {
parseInt() = 0;
} catch(e) {
caught = true;
}
assertTrue(caught);
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