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

Side by Side Diff: src/ast.cc

Issue 1132005: Add iterative primitive type analysis.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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/compiler.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 73
74 VariableProxy::VariableProxy(Handle<String> name, 74 VariableProxy::VariableProxy(Handle<String> name,
75 bool is_this, 75 bool is_this,
76 bool inside_with) 76 bool inside_with)
77 : name_(name), 77 : name_(name),
78 var_(NULL), 78 var_(NULL),
79 is_this_(is_this), 79 is_this_(is_this),
80 inside_with_(inside_with), 80 inside_with_(inside_with),
81 is_trivial_(false), 81 is_trivial_(false),
82 reaching_definitions_(NULL) { 82 reaching_definitions_(NULL),
83 is_primitive_(false) {
83 // names must be canonicalized for fast equality checks 84 // names must be canonicalized for fast equality checks
84 ASSERT(name->IsSymbol()); 85 ASSERT(name->IsSymbol());
85 } 86 }
86 87
87 88
88 VariableProxy::VariableProxy(bool is_this) 89 VariableProxy::VariableProxy(bool is_this)
89 : is_this_(is_this), 90 : is_this_(is_this),
90 reaching_definitions_(NULL) { 91 reaching_definitions_(NULL),
92 is_primitive_(false) {
91 } 93 }
92 94
93 95
94 void VariableProxy::BindTo(Variable* var) { 96 void VariableProxy::BindTo(Variable* var) {
95 ASSERT(var_ == NULL); // must be bound only once 97 ASSERT(var_ == NULL); // must be bound only once
96 ASSERT(var != NULL); // must bind 98 ASSERT(var != NULL); // must bind
97 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); 99 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name()));
98 // Ideally CONST-ness should match. However, this is very hard to achieve 100 // Ideally CONST-ness should match. However, this is very hard to achieve
99 // because we don't know the exact semantics of conflicting (const and 101 // because we don't know the exact semantics of conflicting (const and
100 // non-const) multiple variable declarations, const vars introduced via 102 // non-const) multiple variable declarations, const vars introduced via
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 bool RegExpLiteral::IsPrimitive() { return false; } 513 bool RegExpLiteral::IsPrimitive() { return false; }
512 bool ObjectLiteral::IsPrimitive() { return false; } 514 bool ObjectLiteral::IsPrimitive() { return false; }
513 bool ArrayLiteral::IsPrimitive() { return false; } 515 bool ArrayLiteral::IsPrimitive() { return false; }
514 bool CatchExtensionObject::IsPrimitive() { return false; } 516 bool CatchExtensionObject::IsPrimitive() { return false; }
515 bool CallNew::IsPrimitive() { return false; } 517 bool CallNew::IsPrimitive() { return false; }
516 bool ThisFunction::IsPrimitive() { return false; } 518 bool ThisFunction::IsPrimitive() { return false; }
517 519
518 520
519 // The following expression types are not always primitive because we do not 521 // The following expression types are not always primitive because we do not
520 // have enough information to conclude that they are. 522 // have enough information to conclude that they are.
521 bool VariableProxy::IsPrimitive() { return false; }
522 bool Property::IsPrimitive() { return false; } 523 bool Property::IsPrimitive() { return false; }
523 bool Call::IsPrimitive() { return false; } 524 bool Call::IsPrimitive() { return false; }
524 bool CallRuntime::IsPrimitive() { return false; } 525 bool CallRuntime::IsPrimitive() { return false; }
525 526
526 527
528 // A variable use is not primitive unless the primitive-type analysis
529 // determines otherwise.
530 bool VariableProxy::IsPrimitive() {
531 ASSERT(!is_primitive_ || (var() != NULL && var()->IsStackAllocated()));
532 return is_primitive_;
533 }
534
527 // The value of a conditional is the value of one of the alternatives. It's 535 // The value of a conditional is the value of one of the alternatives. It's
528 // always primitive if both alternatives are always primitive. 536 // always primitive if both alternatives are always primitive.
529 bool Conditional::IsPrimitive() { 537 bool Conditional::IsPrimitive() {
530 return then_expression()->IsPrimitive() && else_expression()->IsPrimitive(); 538 return then_expression()->IsPrimitive() && else_expression()->IsPrimitive();
531 } 539 }
532 540
533 541
534 // A literal is primitive when it is not a JSObject. 542 // A literal is primitive when it is not a JSObject.
535 bool Literal::IsPrimitive() { return !handle()->IsJSObject(); } 543 bool Literal::IsPrimitive() { return !handle()->IsJSObject(); }
536 544
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 SetStackOverflow(); 978 SetStackOverflow();
971 } 979 }
972 980
973 981
974 void CopyAstVisitor::VisitDeclaration(Declaration* decl) { 982 void CopyAstVisitor::VisitDeclaration(Declaration* decl) {
975 UNREACHABLE(); 983 UNREACHABLE();
976 } 984 }
977 985
978 986
979 } } // namespace v8::internal 987 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698