summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler.cc
diff options
context:
space:
mode:
authorRyan <ry@tinyclouds.org>2009-06-08 18:34:06 +0200
committerRyan <ry@tinyclouds.org>2009-06-08 18:34:06 +0200
commit696f02455792b368249bf9b013dde637b5ec31fd (patch)
tree95b2dbd6c2537df9df52f6627aac36fcf05f6a7a /deps/v8/src/compiler.cc
parentf6a7fe26574defaa807a13248102ebe0f23270af (diff)
downloadnode-696f02455792b368249bf9b013dde637b5ec31fd.tar.gz
Upgrade to v8 1.2.7
Diffstat (limited to 'deps/v8/src/compiler.cc')
-rw-r--r--deps/v8/src/compiler.cc49
1 files changed, 33 insertions, 16 deletions
diff --git a/deps/v8/src/compiler.cc b/deps/v8/src/compiler.cc
index 256c69696..ea7c134da 100644
--- a/deps/v8/src/compiler.cc
+++ b/deps/v8/src/compiler.cc
@@ -37,7 +37,8 @@
#include "scopes.h"
#include "usage-analyzer.h"
-namespace v8 { namespace internal {
+namespace v8 {
+namespace internal {
static Handle<Code> MakeCode(FunctionLiteral* literal,
Handle<Script> script,
@@ -52,12 +53,15 @@ static Handle<Code> MakeCode(FunctionLiteral* literal,
return Handle<Code>::null();
}
- // Compute top scope and allocate variables. For lazy compilation
- // the top scope only contains the single lazily compiled function,
- // so this doesn't re-allocate variables repeatedly.
- Scope* top = literal->scope();
- while (top->outer_scope() != NULL) top = top->outer_scope();
- top->AllocateVariables(context);
+ {
+ // Compute top scope and allocate variables. For lazy compilation
+ // the top scope only contains the single lazily compiled function,
+ // so this doesn't re-allocate variables repeatedly.
+ HistogramTimerScope timer(&Counters::variable_allocation);
+ Scope* top = literal->scope();
+ while (top->outer_scope() != NULL) top = top->outer_scope();
+ top->AllocateVariables(context);
+ }
#ifdef DEBUG
if (Bootstrapper::IsActive() ?
@@ -86,7 +90,7 @@ static bool IsValidJSON(FunctionLiteral* lit) {
Statement* stmt = lit->body()->at(0);
if (stmt->AsExpressionStatement() == NULL)
return false;
- Expression *expr = stmt->AsExpressionStatement()->expression();
+ Expression* expr = stmt->AsExpressionStatement()->expression();
return expr->IsValidJSON();
}
@@ -98,7 +102,7 @@ static Handle<JSFunction> MakeFunction(bool is_global,
Handle<Context> context,
v8::Extension* extension,
ScriptDataImpl* pre_data) {
- ZoneScope zone_scope(DELETE_ON_EXIT);
+ CompilationZoneScope zone_scope(DELETE_ON_EXIT);
// Make sure we have an initial stack limit.
StackGuard guard;
@@ -106,7 +110,22 @@ static Handle<JSFunction> MakeFunction(bool is_global,
ASSERT(!i::Top::global_context().is_null());
script->set_context_data((*i::Top::global_context())->data());
+
#ifdef ENABLE_DEBUGGER_SUPPORT
+ if (is_eval || is_json) {
+ script->set_compilation_type(
+ is_json ? Smi::FromInt(Script::COMPILATION_TYPE_JSON) :
+ Smi::FromInt(Script::COMPILATION_TYPE_EVAL));
+ // For eval scripts add information on the function from which eval was
+ // called.
+ if (is_eval) {
+ JavaScriptFrameIterator it;
+ script->set_eval_from_function(it.frame()->function());
+ int offset = it.frame()->pc() - it.frame()->code()->instruction_start();
+ script->set_eval_from_instructions_offset(Smi::FromInt(offset));
+ }
+ }
+
// Notify debugger
Debugger::OnBeforeCompile(script);
#endif
@@ -156,7 +175,7 @@ static Handle<JSFunction> MakeFunction(bool is_global,
#if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT
// Log the code generation for the script. Check explicit whether logging is
// to avoid allocating when not required.
- if (Logger::is_enabled() || OProfileAgent::is_enabled()) {
+ if (Logger::IsEnabled() || OProfileAgent::is_enabled()) {
if (script->name()->IsString()) {
SmartPointer<char> data =
String::cast(script->name())->ToCString(DISALLOW_NULLS);
@@ -264,7 +283,6 @@ Handle<JSFunction> Compiler::Compile(Handle<String> source,
Handle<JSFunction> Compiler::CompileEval(Handle<String> source,
Handle<Context> context,
- int line_offset,
bool is_global,
bool is_json) {
int source_length = source->length();
@@ -284,7 +302,6 @@ Handle<JSFunction> Compiler::CompileEval(Handle<String> source,
if (result.is_null()) {
// Create a script object describing the script to be compiled.
Handle<Script> script = Factory::NewScript(source);
- script->set_line_offset(Smi::FromInt(line_offset));
result = MakeFunction(is_global,
true,
is_json,
@@ -303,7 +320,7 @@ Handle<JSFunction> Compiler::CompileEval(Handle<String> source,
bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared,
int loop_nesting) {
- ZoneScope zone_scope(DELETE_ON_EXIT);
+ CompilationZoneScope zone_scope(DELETE_ON_EXIT);
// The VM is in the COMPILER state until exiting this function.
VMState state(COMPILER);
@@ -355,9 +372,9 @@ bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared,
// Log the code generation. If source information is available include script
// name and line number. Check explicit whether logging is enabled as finding
// the line number is not for free.
- if (Logger::is_enabled() || OProfileAgent::is_enabled()) {
- Handle<String> func_name(lit->name()->length() > 0 ?
- *lit->name() : shared->inferred_name());
+ if (Logger::IsEnabled() || OProfileAgent::is_enabled()) {
+ Handle<String> func_name(name->length() > 0 ?
+ *name : shared->inferred_name());
if (script->name()->IsString()) {
int line_num = GetScriptLineNumber(script, start_position);
if (line_num > 0) {