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

Side by Side Diff: src/compiler.cc

Issue 264067: Initial port of top-level code generator to ARM. For the constant... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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/arm/fast-codegen-arm.cc ('k') | src/fast-codegen.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 23 matching lines...) Expand all
34 #include "debug.h" 34 #include "debug.h"
35 #include "fast-codegen.h" 35 #include "fast-codegen.h"
36 #include "oprofile-agent.h" 36 #include "oprofile-agent.h"
37 #include "rewriter.h" 37 #include "rewriter.h"
38 #include "scopes.h" 38 #include "scopes.h"
39 #include "usage-analyzer.h" 39 #include "usage-analyzer.h"
40 40
41 namespace v8 { 41 namespace v8 {
42 namespace internal { 42 namespace internal {
43 43
44 #ifndef V8_TARGET_ARCH_ARM
45 44
46 class CodeGenSelector: public AstVisitor { 45 class CodeGenSelector: public AstVisitor {
47 public: 46 public:
48 enum CodeGenTag { NORMAL, FAST }; 47 enum CodeGenTag { NORMAL, FAST };
49 48
50 CodeGenSelector() : has_supported_syntax_(true) {} 49 CodeGenSelector() : has_supported_syntax_(true) {}
51 50
52 CodeGenTag Select(FunctionLiteral* fun); 51 CodeGenTag Select(FunctionLiteral* fun);
53 52
54 private: 53 private:
55 void VisitStatements(ZoneList<Statement*>* stmts); 54 void VisitStatements(ZoneList<Statement*>* stmts);
56 55
57 // AST node visit functions. 56 // AST node visit functions.
58 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); 57 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
59 AST_NODE_LIST(DECLARE_VISIT) 58 AST_NODE_LIST(DECLARE_VISIT)
60 #undef DECLARE_VISIT 59 #undef DECLARE_VISIT
61 60
62 bool has_supported_syntax_; 61 bool has_supported_syntax_;
63 62
64 DISALLOW_COPY_AND_ASSIGN(CodeGenSelector); 63 DISALLOW_COPY_AND_ASSIGN(CodeGenSelector);
65 }; 64 };
66 65
67 #endif
68
69 66
70 static Handle<Code> MakeCode(FunctionLiteral* literal, 67 static Handle<Code> MakeCode(FunctionLiteral* literal,
71 Handle<Script> script, 68 Handle<Script> script,
72 Handle<Context> context, 69 Handle<Context> context,
73 bool is_eval) { 70 bool is_eval) {
74 ASSERT(literal != NULL); 71 ASSERT(literal != NULL);
75 72
76 // Rewrite the AST by introducing .result assignments where needed. 73 // Rewrite the AST by introducing .result assignments where needed.
77 if (!Rewriter::Process(literal) || !AnalyzeVariableUsage(literal)) { 74 if (!Rewriter::Process(literal) || !AnalyzeVariableUsage(literal)) {
78 // Signal a stack overflow by returning a null handle. The stack 75 // Signal a stack overflow by returning a null handle. The stack
(...skipping 20 matching lines...) Expand all
99 #endif 96 #endif
100 97
101 // Optimize the AST. 98 // Optimize the AST.
102 if (!Rewriter::Optimize(literal)) { 99 if (!Rewriter::Optimize(literal)) {
103 // Signal a stack overflow by returning a null handle. The stack 100 // Signal a stack overflow by returning a null handle. The stack
104 // overflow exception will be thrown by the caller. 101 // overflow exception will be thrown by the caller.
105 return Handle<Code>::null(); 102 return Handle<Code>::null();
106 } 103 }
107 104
108 // Generate code and return it. 105 // Generate code and return it.
109 #ifndef V8_TARGET_ARCH_ARM
110 if (FLAG_fast_compiler) { 106 if (FLAG_fast_compiler) {
111 CodeGenSelector selector; 107 CodeGenSelector selector;
112 CodeGenSelector::CodeGenTag code_gen = selector.Select(literal); 108 CodeGenSelector::CodeGenTag code_gen = selector.Select(literal);
113 if (code_gen == CodeGenSelector::FAST) { 109 if (code_gen == CodeGenSelector::FAST) {
114 return FastCodeGenerator::MakeCode(literal, script); 110 return FastCodeGenerator::MakeCode(literal, script);
115 } 111 }
116 ASSERT(code_gen == CodeGenSelector::NORMAL); 112 ASSERT(code_gen == CodeGenSelector::NORMAL);
117 } 113 }
118 #endif
119
120 return CodeGenerator::MakeCode(literal, script, is_eval); 114 return CodeGenerator::MakeCode(literal, script, is_eval);
121 } 115 }
122 116
123 117
124 static bool IsValidJSON(FunctionLiteral* lit) { 118 static bool IsValidJSON(FunctionLiteral* lit) {
125 if (lit->body()->length() != 1) 119 if (lit->body()->length() != 1)
126 return false; 120 return false;
127 Statement* stmt = lit->body()->at(0); 121 Statement* stmt = lit->body()->at(0);
128 if (stmt->AsExpressionStatement() == NULL) 122 if (stmt->AsExpressionStatement() == NULL)
129 return false; 123 return false;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 lit->has_only_this_property_assignments(), 440 lit->has_only_this_property_assignments(),
447 lit->has_only_simple_this_property_assignments(), 441 lit->has_only_simple_this_property_assignments(),
448 *lit->this_property_assignments()); 442 *lit->this_property_assignments());
449 443
450 // Check the function has compiled code. 444 // Check the function has compiled code.
451 ASSERT(shared->is_compiled()); 445 ASSERT(shared->is_compiled());
452 return true; 446 return true;
453 } 447 }
454 448
455 449
456 #ifndef V8_TARGET_ARCH_ARM
457
458 CodeGenSelector::CodeGenTag CodeGenSelector::Select(FunctionLiteral* fun) { 450 CodeGenSelector::CodeGenTag CodeGenSelector::Select(FunctionLiteral* fun) {
459 Scope* scope = fun->scope(); 451 Scope* scope = fun->scope();
460 452
461 if (!scope->is_global_scope()) return NORMAL; 453 if (!scope->is_global_scope()) return NORMAL;
462 ASSERT(scope->num_heap_slots() == 0); 454 ASSERT(scope->num_heap_slots() == 0);
463 ASSERT(scope->arguments() == NULL); 455 ASSERT(scope->arguments() == NULL);
464 456
465 if (!scope->declarations()->is_empty()) return NORMAL; 457 if (!scope->declarations()->is_empty()) return NORMAL;
466 if (fun->materialized_literal_count() > 0) return NORMAL; 458 if (fun->materialized_literal_count() > 0) return NORMAL;
467 if (fun->body()->is_empty()) return NORMAL; 459 if (fun->body()->is_empty()) return NORMAL;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 703 }
712 704
713 705
714 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) { 706 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) {
715 BAILOUT("ThisFunction"); 707 BAILOUT("ThisFunction");
716 } 708 }
717 709
718 #undef BAILOUT 710 #undef BAILOUT
719 #undef CHECK_BAILOUT 711 #undef CHECK_BAILOUT
720 712
721 #endif // !defined(V8_TARGET_ARCH_ARM)
722
723 713
724 } } // namespace v8::internal 714 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/fast-codegen-arm.cc ('k') | src/fast-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698