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

Side by Side Diff: src/ast.cc

Issue 17576005: Rename Literal::handle to Literal::value (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 void type::Accept(AstVisitor* v) { v->Visit##type(this); } 50 void type::Accept(AstVisitor* v) { v->Visit##type(this); }
51 AST_NODE_LIST(DECL_ACCEPT) 51 AST_NODE_LIST(DECL_ACCEPT)
52 #undef DECL_ACCEPT 52 #undef DECL_ACCEPT
53 53
54 54
55 // ---------------------------------------------------------------------------- 55 // ----------------------------------------------------------------------------
56 // Implementation of other node functionality. 56 // Implementation of other node functionality.
57 57
58 58
59 bool Expression::IsSmiLiteral() { 59 bool Expression::IsSmiLiteral() {
60 return AsLiteral() != NULL && AsLiteral()->handle()->IsSmi(); 60 return AsLiteral() != NULL && AsLiteral()->value()->IsSmi();
61 } 61 }
62 62
63 63
64 bool Expression::IsStringLiteral() { 64 bool Expression::IsStringLiteral() {
65 return AsLiteral() != NULL && AsLiteral()->handle()->IsString(); 65 return AsLiteral() != NULL && AsLiteral()->value()->IsString();
66 } 66 }
67 67
68 68
69 bool Expression::IsNullLiteral() { 69 bool Expression::IsNullLiteral() {
70 return AsLiteral() != NULL && AsLiteral()->handle()->IsNull(); 70 return AsLiteral() != NULL && AsLiteral()->value()->IsNull();
71 } 71 }
72 72
73 73
74 bool Expression::IsUndefinedLiteral() { 74 bool Expression::IsUndefinedLiteral() {
75 return AsLiteral() != NULL && AsLiteral()->handle()->IsUndefined(); 75 return AsLiteral() != NULL && AsLiteral()->value()->IsUndefined();
76 } 76 }
77 77
78 78
79 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) 79 VariableProxy::VariableProxy(Isolate* isolate, Variable* var)
80 : Expression(isolate), 80 : Expression(isolate),
81 name_(var->name()), 81 name_(var->name()),
82 var_(NULL), // Will be set by the call to BindTo. 82 var_(NULL), // Will be set by the call to BindTo.
83 is_this_(var->is_this()), 83 is_this_(var->is_this()),
84 is_trivial_(false), 84 is_trivial_(false),
85 is_lvalue_(false), 85 is_lvalue_(false),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return scope()->language_mode(); 182 return scope()->language_mode();
183 } 183 }
184 184
185 185
186 ObjectLiteralProperty::ObjectLiteralProperty(Literal* key, 186 ObjectLiteralProperty::ObjectLiteralProperty(Literal* key,
187 Expression* value, 187 Expression* value,
188 Isolate* isolate) { 188 Isolate* isolate) {
189 emit_store_ = true; 189 emit_store_ = true;
190 key_ = key; 190 key_ = key;
191 value_ = value; 191 value_ = value;
192 Object* k = *key->handle(); 192 Object* k = *key->value();
193 if (k->IsInternalizedString() && 193 if (k->IsInternalizedString() &&
194 isolate->heap()->proto_string()->Equals(String::cast(k))) { 194 isolate->heap()->proto_string()->Equals(String::cast(k))) {
195 kind_ = PROTOTYPE; 195 kind_ = PROTOTYPE;
196 } else if (value_->AsMaterializedLiteral() != NULL) { 196 } else if (value_->AsMaterializedLiteral() != NULL) {
197 kind_ = MATERIALIZED_LITERAL; 197 kind_ = MATERIALIZED_LITERAL;
198 } else if (value_->AsLiteral() != NULL) { 198 } else if (value_->AsLiteral() != NULL) {
199 kind_ = CONSTANT; 199 kind_ = CONSTANT;
200 } else { 200 } else {
201 kind_ = COMPUTED; 201 kind_ = COMPUTED;
202 } 202 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 257
258 void ObjectLiteral::CalculateEmitStore(Zone* zone) { 258 void ObjectLiteral::CalculateEmitStore(Zone* zone) {
259 ZoneAllocationPolicy allocator(zone); 259 ZoneAllocationPolicy allocator(zone);
260 260
261 ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity, 261 ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity,
262 allocator); 262 allocator);
263 for (int i = properties()->length() - 1; i >= 0; i--) { 263 for (int i = properties()->length() - 1; i >= 0; i--) {
264 ObjectLiteral::Property* property = properties()->at(i); 264 ObjectLiteral::Property* property = properties()->at(i);
265 Literal* literal = property->key(); 265 Literal* literal = property->key();
266 if (literal->handle()->IsNull()) continue; 266 if (literal->value()->IsNull()) continue;
267 uint32_t hash = literal->Hash(); 267 uint32_t hash = literal->Hash();
268 // If the key of a computed property is in the table, do not emit 268 // If the key of a computed property is in the table, do not emit
269 // a store for the property later. 269 // a store for the property later.
270 if (property->kind() == ObjectLiteral::Property::COMPUTED && 270 if (property->kind() == ObjectLiteral::Property::COMPUTED &&
271 table.Lookup(literal, hash, false, allocator) != NULL) { 271 table.Lookup(literal, hash, false, allocator) != NULL) {
272 property->set_emit_store(false); 272 property->set_emit_store(false);
273 } else { 273 } else {
274 // Add key to the table. 274 // Add key to the table.
275 table.Lookup(literal, hash, true, allocator); 275 table.Lookup(literal, hash, true, allocator);
276 } 276 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 332
333 // Check for the pattern: typeof <expression> equals <string literal>. 333 // Check for the pattern: typeof <expression> equals <string literal>.
334 static bool MatchLiteralCompareTypeof(Expression* left, 334 static bool MatchLiteralCompareTypeof(Expression* left,
335 Token::Value op, 335 Token::Value op,
336 Expression* right, 336 Expression* right,
337 Expression** expr, 337 Expression** expr,
338 Handle<String>* check) { 338 Handle<String>* check) {
339 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { 339 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) {
340 *expr = left->AsUnaryOperation()->expression(); 340 *expr = left->AsUnaryOperation()->expression();
341 *check = Handle<String>::cast(right->AsLiteral()->handle()); 341 *check = Handle<String>::cast(right->AsLiteral()->value());
342 return true; 342 return true;
343 } 343 }
344 return false; 344 return false;
345 } 345 }
346 346
347 347
348 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, 348 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr,
349 Handle<String>* check) { 349 Handle<String>* check) {
350 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || 350 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) ||
351 MatchLiteralCompareTypeof(right_, op_, left_, expr, check); 351 MatchLiteralCompareTypeof(right_, op_, left_, expr, check);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 receiver_types_.Clear(); 442 receiver_types_.Clear();
443 if (key()->IsPropertyName()) { 443 if (key()->IsPropertyName()) {
444 FunctionPrototypeStub proto_stub(Code::LOAD_IC); 444 FunctionPrototypeStub proto_stub(Code::LOAD_IC);
445 StringLengthStub string_stub(Code::LOAD_IC, false); 445 StringLengthStub string_stub(Code::LOAD_IC, false);
446 if (oracle->LoadIsStub(this, &string_stub)) { 446 if (oracle->LoadIsStub(this, &string_stub)) {
447 is_string_length_ = true; 447 is_string_length_ = true;
448 } else if (oracle->LoadIsStub(this, &proto_stub)) { 448 } else if (oracle->LoadIsStub(this, &proto_stub)) {
449 is_function_prototype_ = true; 449 is_function_prototype_ = true;
450 } else { 450 } else {
451 Literal* lit_key = key()->AsLiteral(); 451 Literal* lit_key = key()->AsLiteral();
452 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); 452 ASSERT(lit_key != NULL && lit_key->value()->IsString());
453 Handle<String> name = Handle<String>::cast(lit_key->handle()); 453 Handle<String> name = Handle<String>::cast(lit_key->value());
454 oracle->LoadReceiverTypes(this, name, &receiver_types_); 454 oracle->LoadReceiverTypes(this, name, &receiver_types_);
455 } 455 }
456 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { 456 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) {
457 is_string_access_ = true; 457 is_string_access_ = true;
458 } else if (is_monomorphic_) { 458 } else if (is_monomorphic_) {
459 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this), 459 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this),
460 zone); 460 zone);
461 } else if (oracle->LoadIsPolymorphic(this)) { 461 } else if (oracle->LoadIsPolymorphic(this)) {
462 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); 462 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
463 oracle->CollectKeyedReceiverTypes(PropertyFeedbackId(), &receiver_types_); 463 oracle->CollectKeyedReceiverTypes(PropertyFeedbackId(), &receiver_types_);
464 } 464 }
465 } 465 }
466 466
467 467
468 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle, 468 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle,
469 Zone* zone) { 469 Zone* zone) {
470 Property* prop = target()->AsProperty(); 470 Property* prop = target()->AsProperty();
471 ASSERT(prop != NULL); 471 ASSERT(prop != NULL);
472 TypeFeedbackId id = AssignmentFeedbackId(); 472 TypeFeedbackId id = AssignmentFeedbackId();
473 is_uninitialized_ = oracle->StoreIsUninitialized(id); 473 is_uninitialized_ = oracle->StoreIsUninitialized(id);
474 if (is_uninitialized_) return; 474 if (is_uninitialized_) return;
475 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); 475 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id);
476 receiver_types_.Clear(); 476 receiver_types_.Clear();
477 if (prop->key()->IsPropertyName()) { 477 if (prop->key()->IsPropertyName()) {
478 Literal* lit_key = prop->key()->AsLiteral(); 478 Literal* lit_key = prop->key()->AsLiteral();
479 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); 479 ASSERT(lit_key != NULL && lit_key->value()->IsString());
480 Handle<String> name = Handle<String>::cast(lit_key->handle()); 480 Handle<String> name = Handle<String>::cast(lit_key->value());
481 oracle->StoreReceiverTypes(this, name, &receiver_types_); 481 oracle->StoreReceiverTypes(this, name, &receiver_types_);
482 } else if (is_monomorphic_) { 482 } else if (is_monomorphic_) {
483 // Record receiver type for monomorphic keyed stores. 483 // Record receiver type for monomorphic keyed stores.
484 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone); 484 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone);
485 store_mode_ = oracle->GetStoreMode(id); 485 store_mode_ = oracle->GetStoreMode(id);
486 } else if (oracle->StoreIsPolymorphic(id)) { 486 } else if (oracle->StoreIsPolymorphic(id)) {
487 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); 487 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
488 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); 488 oracle->CollectKeyedReceiverTypes(id, &receiver_types_);
489 store_mode_ = oracle->GetStoreMode(id); 489 store_mode_ = oracle->GetStoreMode(id);
490 } 490 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle, 612 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle,
613 CallKind call_kind) { 613 CallKind call_kind) {
614 is_monomorphic_ = oracle->CallIsMonomorphic(this); 614 is_monomorphic_ = oracle->CallIsMonomorphic(this);
615 Property* property = expression()->AsProperty(); 615 Property* property = expression()->AsProperty();
616 if (property == NULL) { 616 if (property == NULL) {
617 // Function call. Specialize for monomorphic calls. 617 // Function call. Specialize for monomorphic calls.
618 if (is_monomorphic_) target_ = oracle->GetCallTarget(this); 618 if (is_monomorphic_) target_ = oracle->GetCallTarget(this);
619 } else { 619 } else {
620 // Method call. Specialize for the receiver types seen at runtime. 620 // Method call. Specialize for the receiver types seen at runtime.
621 Literal* key = property->key()->AsLiteral(); 621 Literal* key = property->key()->AsLiteral();
622 ASSERT(key != NULL && key->handle()->IsString()); 622 ASSERT(key != NULL && key->value()->IsString());
623 Handle<String> name = Handle<String>::cast(key->handle()); 623 Handle<String> name = Handle<String>::cast(key->value());
624 receiver_types_.Clear(); 624 receiver_types_.Clear();
625 oracle->CallReceiverTypes(this, name, call_kind, &receiver_types_); 625 oracle->CallReceiverTypes(this, name, call_kind, &receiver_types_);
626 #ifdef DEBUG 626 #ifdef DEBUG
627 if (FLAG_enable_slow_asserts) { 627 if (FLAG_enable_slow_asserts) {
628 int length = receiver_types_.length(); 628 int length = receiver_types_.length();
629 for (int i = 0; i < length; i++) { 629 for (int i = 0; i < length; i++) {
630 Handle<Map> map = receiver_types_.at(i); 630 Handle<Map> map = receiver_types_.at(i);
631 ASSERT(!map.is_null() && *map != NULL); 631 ASSERT(!map.is_null() && *map != NULL);
632 } 632 }
633 } 633 }
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 } 1145 }
1146 } 1146 }
1147 1147
1148 #undef REGULAR_NODE 1148 #undef REGULAR_NODE
1149 #undef DONT_OPTIMIZE_NODE 1149 #undef DONT_OPTIMIZE_NODE
1150 #undef DONT_SELFOPTIMIZE_NODE 1150 #undef DONT_SELFOPTIMIZE_NODE
1151 #undef DONT_CACHE_NODE 1151 #undef DONT_CACHE_NODE
1152 1152
1153 1153
1154 Handle<String> Literal::ToString() { 1154 Handle<String> Literal::ToString() {
1155 if (handle_->IsString()) return Handle<String>::cast(handle_); 1155 if (value_->IsString()) return Handle<String>::cast(value_);
1156 Factory* factory = Isolate::Current()->factory(); 1156 Factory* factory = Isolate::Current()->factory();
1157 ASSERT(handle_->IsNumber()); 1157 ASSERT(value_->IsNumber());
1158 char arr[100]; 1158 char arr[100];
1159 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 1159 Vector<char> buffer(arr, ARRAY_SIZE(arr));
1160 const char* str; 1160 const char* str;
1161 if (handle_->IsSmi()) { 1161 if (value_->IsSmi()) {
1162 // Optimization only, the heap number case would subsume this. 1162 // Optimization only, the heap number case would subsume this.
1163 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); 1163 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1164 str = arr; 1164 str = arr;
1165 } else { 1165 } else {
1166 str = DoubleToCString(handle_->Number(), buffer); 1166 str = DoubleToCString(value_->Number(), buffer);
1167 } 1167 }
1168 return factory->NewStringFromAscii(CStrVector(str)); 1168 return factory->NewStringFromAscii(CStrVector(str));
1169 } 1169 }
1170 1170
1171 1171
1172 } } // namespace v8::internal 1172 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698