Revision: 25019
Author: [email protected]
Date: Thu Oct 30 14:21:27 2014 UTC
Log: Do not embed array objects in unoptimized code.
[email protected]
Review URL: https://codereview.chromium.org/685393002
https://code.google.com/p/v8/source/detail?r=25019
Added:
/branches/bleeding_edge/test/mjsunit/serialize-embedded-error.js
Modified:
/branches/bleeding_edge/src/ast-value-factory.cc
/branches/bleeding_edge/src/ast-value-factory.h
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/messages.js
/branches/bleeding_edge/src/parser.cc
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/mjsunit/serialize-embedded-error.js Thu
Oct 30 14:21:27 2014 UTC
@@ -0,0 +1,13 @@
+// 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);
=======================================
--- /branches/bleeding_edge/src/ast-value-factory.cc Fri Oct 24 13:02:23
2014 UTC
+++ /branches/bleeding_edge/src/ast-value-factory.cc Thu Oct 30 14:21:27
2014 UTC
@@ -159,9 +159,6 @@
return DoubleToBoolean(number_);
case SMI:
return smi_ != 0;
- case STRING_ARRAY:
- UNREACHABLE();
- break;
case BOOLEAN:
return bool_;
case NULL_TYPE:
@@ -202,22 +199,6 @@
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;
@@ -347,17 +328,6 @@
} else {
GENERATE_VALUE_GETTER(false_value_, false);
}
-}
-
-
-const AstValue* AstValueFactory::NewStringList(
- ZoneList<const AstRawString*>* strings) {
- AstValue* value = new (zone_) AstValue(strings);
- if (isolate_) {
- value->Internalize(isolate_);
- }
- values_.Add(value);
- return value;
}
=======================================
--- /branches/bleeding_edge/src/ast-value-factory.h Fri Oct 24 13:02:23
2014 UTC
+++ /branches/bleeding_edge/src/ast-value-factory.h Thu Oct 30 14:21:27
2014 UTC
@@ -194,7 +194,6 @@
NUMBER,
SMI,
BOOLEAN,
- STRING_ARRAY,
NULL_TYPE,
UNDEFINED,
THE_HOLE
@@ -212,10 +211,6 @@
}
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 @@
// 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) \
=======================================
--- /branches/bleeding_edge/src/ast.h Wed Oct 29 18:31:01 2014 UTC
+++ /branches/bleeding_edge/src/ast.h Thu Oct 30 14:21:27 2014 UTC
@@ -3414,13 +3414,6 @@
new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos);
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 =
=======================================
--- /branches/bleeding_edge/src/messages.js Tue Oct 28 12:23:26 2014 UTC
+++ /branches/bleeding_edge/src/messages.js Thu Oct 30 14:21:27 2014 UTC
@@ -366,6 +366,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.
=======================================
--- /branches/bleeding_edge/src/parser.cc Thu Oct 23 12:30:20 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc Thu Oct 30 14:21:27 2014 UTC
@@ -519,7 +519,7 @@
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 @@
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);
--
--
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.