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

Side by Side Diff: src/parsing/parser.cc

Issue 2485423002: Adding smi cache (Closed)
Patch Set: Changed signature to uint Created 4 years, 1 month 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
« no previous file with comments | « src/ast/ast-value-factory.cc ('k') | src/parsing/scanner.h » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 495
496 Literal* Parser::ExpressionFromLiteral(Token::Value token, int pos) { 496 Literal* Parser::ExpressionFromLiteral(Token::Value token, int pos) {
497 switch (token) { 497 switch (token) {
498 case Token::NULL_LITERAL: 498 case Token::NULL_LITERAL:
499 return factory()->NewNullLiteral(pos); 499 return factory()->NewNullLiteral(pos);
500 case Token::TRUE_LITERAL: 500 case Token::TRUE_LITERAL:
501 return factory()->NewBooleanLiteral(true, pos); 501 return factory()->NewBooleanLiteral(true, pos);
502 case Token::FALSE_LITERAL: 502 case Token::FALSE_LITERAL:
503 return factory()->NewBooleanLiteral(false, pos); 503 return factory()->NewBooleanLiteral(false, pos);
504 case Token::SMI: { 504 case Token::SMI: {
505 int value = scanner()->smi_value(); 505 uint32_t value = scanner()->smi_value();
506 return factory()->NewSmiLiteral(value, pos); 506 return factory()->NewSmiLiteral(value, pos);
507 } 507 }
508 case Token::NUMBER: { 508 case Token::NUMBER: {
509 bool has_dot = scanner()->ContainsDot(); 509 bool has_dot = scanner()->ContainsDot();
510 double value = scanner()->DoubleValue(); 510 double value = scanner()->DoubleValue();
511 return factory()->NewNumberLiteral(value, pos, has_dot); 511 return factory()->NewNumberLiteral(value, pos, has_dot);
512 } 512 }
513 default: 513 default:
514 DCHECK(false); 514 DCHECK(false);
515 } 515 }
(...skipping 3398 matching lines...) Expand 10 before | Expand all | Expand 10 after
3914 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(4, zone()); 3914 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(4, zone());
3915 args->Add(factory()->NewArrayLiteral( 3915 args->Add(factory()->NewArrayLiteral(
3916 const_cast<ZoneList<Expression*>*>(cooked_strings), 3916 const_cast<ZoneList<Expression*>*>(cooked_strings),
3917 cooked_idx, pos), 3917 cooked_idx, pos),
3918 zone()); 3918 zone());
3919 args->Add( 3919 args->Add(
3920 factory()->NewArrayLiteral( 3920 factory()->NewArrayLiteral(
3921 const_cast<ZoneList<Expression*>*>(raw_strings), raw_idx, pos), 3921 const_cast<ZoneList<Expression*>*>(raw_strings), raw_idx, pos),
3922 zone()); 3922 zone());
3923 3923
3924 // Ensure hash is suitable as a Smi value 3924 // Truncate hash to Smi-range.
3925 Smi* hash_obj = Smi::cast(Internals::IntToSmi(static_cast<int>(hash))); 3925 Smi* hash_obj = Smi::cast(Internals::IntToSmi(static_cast<int>(hash)));
3926 args->Add(factory()->NewSmiLiteral(hash_obj->value(), pos), zone()); 3926 args->Add(factory()->NewNumberLiteral(hash_obj->value(), pos), zone());
3927 3927
3928 Expression* call_site = factory()->NewCallRuntime( 3928 Expression* call_site = factory()->NewCallRuntime(
3929 Context::GET_TEMPLATE_CALL_SITE_INDEX, args, start); 3929 Context::GET_TEMPLATE_CALL_SITE_INDEX, args, start);
3930 3930
3931 // Call TagFn 3931 // Call TagFn
3932 ZoneList<Expression*>* call_args = 3932 ZoneList<Expression*>* call_args =
3933 new (zone()) ZoneList<Expression*>(expressions->length() + 1, zone()); 3933 new (zone()) ZoneList<Expression*>(expressions->length() + 1, zone());
3934 call_args->Add(call_site, zone()); 3934 call_args->Add(call_site, zone());
3935 call_args->AddAll(*expressions, zone()); 3935 call_args->AddAll(*expressions, zone());
3936 return factory()->NewCall(tag, call_args, pos); 3936 return factory()->NewCall(tag, call_args, pos);
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
5419 5419
5420 return final_loop; 5420 return final_loop;
5421 } 5421 }
5422 5422
5423 #undef CHECK_OK 5423 #undef CHECK_OK
5424 #undef CHECK_OK_VOID 5424 #undef CHECK_OK_VOID
5425 #undef CHECK_FAILED 5425 #undef CHECK_FAILED
5426 5426
5427 } // namespace internal 5427 } // namespace internal
5428 } // namespace v8 5428 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-value-factory.cc ('k') | src/parsing/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698