Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: src/ast.cc

Issue 345513003: Revert "Parser: Delay internalizing strings and values." (r21841) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast.h ('k') | src/ast-value-factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index dbbba830adb445082b32a7db3482afddad05fe39..d332f4a3cbcf15c8de64e998896f25b06b31532a 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -55,13 +55,14 @@ bool Expression::IsUndefinedLiteral(Isolate* isolate) const {
// The global identifier "undefined" is immutable. Everything
// else could be reassigned.
return var != NULL && var->location() == Variable::UNALLOCATED &&
- var_proxy->raw_name()->IsOneByteEqualTo("undefined");
+ String::Equals(var_proxy->name(),
+ isolate->factory()->undefined_string());
}
VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
: Expression(zone, position),
- name_(var->raw_name()),
+ name_(var->name()),
var_(NULL), // Will be set by the call to BindTo.
is_this_(var->is_this()),
is_trivial_(false),
@@ -72,7 +73,7 @@ VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
VariableProxy::VariableProxy(Zone* zone,
- const AstString* name,
+ Handle<String> name,
bool is_this,
Interface* interface,
int position)
@@ -83,6 +84,8 @@ VariableProxy::VariableProxy(Zone* zone,
is_trivial_(false),
is_lvalue_(false),
interface_(interface) {
+ // Names must be canonicalized for fast equality checks.
+ ASSERT(name->IsInternalizedString());
}
@@ -90,7 +93,7 @@ void VariableProxy::BindTo(Variable* var) {
ASSERT(var_ == NULL); // must be bound only once
ASSERT(var != NULL); // must bind
ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
- ASSERT((is_this() && var->is_this()) || name_ == var->raw_name());
+ ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name()));
// Ideally CONST-ness should match. However, this is very hard to achieve
// because we don't know the exact semantics of conflicting (const and
// non-const) multiple variable declarations, const vars introduced via
@@ -177,13 +180,15 @@ void FunctionLiteral::InitializeSharedInfo(
}
-ObjectLiteralProperty::ObjectLiteralProperty(Zone* zone,
- AstValueFactory* ast_value_factory,
- Literal* key, Expression* value) {
+ObjectLiteralProperty::ObjectLiteralProperty(
+ Zone* zone, Literal* key, Expression* value) {
emit_store_ = true;
key_ = key;
value_ = value;
- if (key->raw_value()->EqualsString(ast_value_factory->proto_string())) {
+ Handle<Object> k = key->value();
+ if (k->IsInternalizedString() &&
+ String::Equals(Handle<String>::cast(k),
+ zone->isolate()->factory()->proto_string())) {
kind_ = PROTOTYPE;
} else if (value_->AsMaterializedLiteral() != NULL) {
kind_ = MATERIALIZED_LITERAL;
@@ -1117,8 +1122,9 @@ void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
// optimize them.
add_flag(kDontInline);
} else if (node->function()->intrinsic_type == Runtime::INLINE &&
- (node->raw_name()->IsOneByteEqualTo("_ArgumentsLength") ||
- node->raw_name()->IsOneByteEqualTo("_Arguments"))) {
+ (node->name()->IsOneByteEqualTo(
+ STATIC_ASCII_VECTOR("_ArgumentsLength")) ||
+ node->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_Arguments")))) {
// Don't inline the %_ArgumentsLength or %_Arguments because their
// implementation will not work. There is no stack frame to get them
// from.
@@ -1133,17 +1139,17 @@ void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
Handle<String> Literal::ToString() {
- if (value_->IsString()) return value_->AsString()->string();
+ if (value_->IsString()) return Handle<String>::cast(value_);
ASSERT(value_->IsNumber());
char arr[100];
Vector<char> buffer(arr, ARRAY_SIZE(arr));
const char* str;
- if (value()->IsSmi()) {
+ if (value_->IsSmi()) {
// Optimization only, the heap number case would subsume this.
- SNPrintF(buffer, "%d", Smi::cast(*value())->value());
+ SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
str = arr;
} else {
- str = DoubleToCString(value()->Number(), buffer);
+ str = DoubleToCString(value_->Number(), buffer);
}
return isolate_->factory()->NewStringFromAsciiChecked(str);
}
« no previous file with comments | « src/ast.h ('k') | src/ast-value-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698