V8 Project
v8::internal::Rewriter Class Reference

#include <rewriter.h>

+ Collaboration diagram for v8::internal::Rewriter:

Static Public Member Functions

static bool Rewrite (CompilationInfo *info)
 

Detailed Description

Definition at line 13 of file rewriter.h.

Member Function Documentation

◆ Rewrite()

bool v8::internal::Rewriter::Rewrite ( CompilationInfo info)
static

Definition at line 230 of file rewriter.cc.

230  {
231  FunctionLiteral* function = info->function();
232  DCHECK(function != NULL);
233  Scope* scope = function->scope();
234  DCHECK(scope != NULL);
235  if (!scope->is_global_scope() && !scope->is_eval_scope()) return true;
236 
237  ZoneList<Statement*>* body = function->body();
238  if (!body->is_empty()) {
239  Variable* result =
240  scope->NewTemporary(info->ast_value_factory()->dot_result_string());
241  // The name string must be internalized at this point.
242  DCHECK(!result->name().is_null());
243  Processor processor(result, info->zone(), info->ast_node_id_gen());
244  processor.Process(body);
245  if (processor.HasStackOverflow()) return false;
246 
247  if (processor.result_assigned()) {
248  DCHECK(function->end_position() != RelocInfo::kNoPosition);
249  // Set the position of the assignment statement one character past the
250  // source code, such that it definitely is not in the source code range
251  // of an immediate inner scope. For example in
252  // eval('with ({x:1}) x = 1');
253  // the end position of the function generated for executing the eval code
254  // coincides with the end of the with scope which is the position of '1'.
255  int pos = function->end_position();
256  VariableProxy* result_proxy = processor.factory()->NewVariableProxy(
257  result->raw_name(), false, result->interface(), pos);
258  result_proxy->BindTo(result);
259  Statement* result_statement =
260  processor.factory()->NewReturnStatement(result_proxy, pos);
261  body->Add(result_statement, info->zone());
262  }
263  }
264 
265  return true;
266 }
static const int kNoPosition
Definition: assembler.h:317
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::CompilationInfo::ast_node_id_gen(), v8::internal::CompilationInfo::ast_value_factory(), DCHECK, v8::internal::Processor::factory(), v8::internal::CompilationInfo::function(), v8::internal::Variable::interface(), v8::internal::Scope::is_eval_scope(), v8::internal::Scope::is_global_scope(), v8::internal::RelocInfo::kNoPosition, v8::internal::Variable::name(), v8::internal::Scope::NewTemporary(), NULL, v8::internal::Processor::Process(), v8::internal::Variable::raw_name(), v8::internal::Processor::result_assigned(), and v8::internal::CompilationInfo::zone().

Referenced by v8::internal::CompileOptimizedPrologue(), v8::internal::CompileUnoptimizedCode(), and v8::internal::compiler::Parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: