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

Side by Side Diff: src/rewriter.cc

Issue 11093074: Get rid of static module allocation, do it in code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed last comments; added other back-ends Created 8 years 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/property-details.h ('k') | src/runtime.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 // 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // list of assignments corresponding to the initialization expressions. 102 // list of assignments corresponding to the initialization expressions.
103 // While unclear from the spec (ECMA-262, 3rd., 12.2), the value of 103 // While unclear from the spec (ECMA-262, 3rd., 12.2), the value of
104 // a variable declaration with initialization expression is 'undefined' 104 // a variable declaration with initialization expression is 'undefined'
105 // with some JS VMs: For instance, using smjs, print(eval('var x = 7')) 105 // with some JS VMs: For instance, using smjs, print(eval('var x = 7'))
106 // returns 'undefined'. To obtain the same behavior with v8, we need 106 // returns 'undefined'. To obtain the same behavior with v8, we need
107 // to prevent rewriting in that case. 107 // to prevent rewriting in that case.
108 if (!node->is_initializer_block()) Process(node->statements()); 108 if (!node->is_initializer_block()) Process(node->statements());
109 } 109 }
110 110
111 111
112 void Processor::VisitModuleStatement(ModuleStatement* node) {
113 bool set_after_body = is_set_;
114 Visit(node->body());
115 is_set_ = is_set_ && set_after_body;
116 }
117
118
112 void Processor::VisitExpressionStatement(ExpressionStatement* node) { 119 void Processor::VisitExpressionStatement(ExpressionStatement* node) {
113 // Rewrite : <x>; -> .result = <x>; 120 // Rewrite : <x>; -> .result = <x>;
114 if (!is_set_ && !node->expression()->IsThrow()) { 121 if (!is_set_ && !node->expression()->IsThrow()) {
115 node->set_expression(SetResult(node->expression())); 122 node->set_expression(SetResult(node->expression()));
116 if (!in_try_) is_set_ = true; 123 if (!in_try_) is_set_ = true;
117 } 124 }
118 } 125 }
119 126
120 127
121 void Processor::VisitIfStatement(IfStatement* node) { 128 void Processor::VisitIfStatement(IfStatement* node) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (processor.result_assigned()) { 257 if (processor.result_assigned()) {
251 ASSERT(function->end_position() != RelocInfo::kNoPosition); 258 ASSERT(function->end_position() != RelocInfo::kNoPosition);
252 // Set the position of the assignment statement one character past the 259 // Set the position of the assignment statement one character past the
253 // source code, such that it definitely is not in the source code range 260 // source code, such that it definitely is not in the source code range
254 // of an immediate inner scope. For example in 261 // of an immediate inner scope. For example in
255 // eval('with ({x:1}) x = 1'); 262 // eval('with ({x:1}) x = 1');
256 // the end position of the function generated for executing the eval code 263 // the end position of the function generated for executing the eval code
257 // coincides with the end of the with scope which is the position of '1'. 264 // coincides with the end of the with scope which is the position of '1'.
258 int position = function->end_position(); 265 int position = function->end_position();
259 VariableProxy* result_proxy = processor.factory()->NewVariableProxy( 266 VariableProxy* result_proxy = processor.factory()->NewVariableProxy(
260 result->name(), false, Interface::NewValue(), position); 267 result->name(), false, result->interface(), position);
261 result_proxy->BindTo(result); 268 result_proxy->BindTo(result);
262 Statement* result_statement = 269 Statement* result_statement =
263 processor.factory()->NewReturnStatement(result_proxy); 270 processor.factory()->NewReturnStatement(result_proxy);
264 result_statement->set_statement_pos(position); 271 result_statement->set_statement_pos(position);
265 body->Add(result_statement, info->zone()); 272 body->Add(result_statement, info->zone());
266 } 273 }
267 } 274 }
268 275
269 return true; 276 return true;
270 } 277 }
271 278
272 279
273 } } // namespace v8::internal 280 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/property-details.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698