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

Side by Side Diff: src/rewriter.cc

Issue 231073002: WIP: Parser: delay string internalization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: internalizing better Created 6 years, 7 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
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 "v8.h" 5 #include "v8.h"
6 6
7 #include "rewriter.h" 7 #include "rewriter.h"
8 8
9 #include "ast.h" 9 #include "ast.h"
10 #include "compiler.h" 10 #include "compiler.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // continue to be used in the case of failure. 227 // continue to be used in the case of failure.
228 bool Rewriter::Rewrite(CompilationInfo* info) { 228 bool Rewriter::Rewrite(CompilationInfo* info) {
229 FunctionLiteral* function = info->function(); 229 FunctionLiteral* function = info->function();
230 ASSERT(function != NULL); 230 ASSERT(function != NULL);
231 Scope* scope = function->scope(); 231 Scope* scope = function->scope();
232 ASSERT(scope != NULL); 232 ASSERT(scope != NULL);
233 if (!scope->is_global_scope() && !scope->is_eval_scope()) return true; 233 if (!scope->is_global_scope() && !scope->is_eval_scope()) return true;
234 234
235 ZoneList<Statement*>* body = function->body(); 235 ZoneList<Statement*>* body = function->body();
236 if (!body->is_empty()) { 236 if (!body->is_empty()) {
237 Variable* result = scope->NewTemporary( 237 Variable* result =
238 info->isolate()->factory()->dot_result_string()); 238 scope->NewTemporary(info->symbol_table()->dot_result_string());
239 ASSERT(!result->name().is_null()); // Gets internalized right away.
239 Processor processor(result, info->zone()); 240 Processor processor(result, info->zone());
240 processor.Process(body); 241 processor.Process(body);
241 if (processor.HasStackOverflow()) return false; 242 if (processor.HasStackOverflow()) return false;
242 243
243 if (processor.result_assigned()) { 244 if (processor.result_assigned()) {
244 ASSERT(function->end_position() != RelocInfo::kNoPosition); 245 ASSERT(function->end_position() != RelocInfo::kNoPosition);
245 // Set the position of the assignment statement one character past the 246 // Set the position of the assignment statement one character past the
246 // source code, such that it definitely is not in the source code range 247 // source code, such that it definitely is not in the source code range
247 // of an immediate inner scope. For example in 248 // of an immediate inner scope. For example in
248 // eval('with ({x:1}) x = 1'); 249 // eval('with ({x:1}) x = 1');
249 // the end position of the function generated for executing the eval code 250 // the end position of the function generated for executing the eval code
250 // coincides with the end of the with scope which is the position of '1'. 251 // coincides with the end of the with scope which is the position of '1'.
251 int pos = function->end_position(); 252 int pos = function->end_position();
252 VariableProxy* result_proxy = processor.factory()->NewVariableProxy( 253 VariableProxy* result_proxy = processor.factory()->NewVariableProxy(
253 result->name(), false, result->interface(), pos); 254 result->raw_name(), false, result->interface(), pos);
254 result_proxy->BindTo(result); 255 result_proxy->BindTo(result);
255 Statement* result_statement = 256 Statement* result_statement =
256 processor.factory()->NewReturnStatement(result_proxy, pos); 257 processor.factory()->NewReturnStatement(result_proxy, pos);
257 body->Add(result_statement, info->zone()); 258 body->Add(result_statement, info->zone());
258 } 259 }
259 } 260 }
260 261
261 return true; 262 return true;
262 } 263 }
263 264
264 265
265 } } // namespace v8::internal 266 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698