mirror of https://github.com/lukechilds/node.git
Ryan Dahl
15 years ago
214 changed files with 20096 additions and 11840 deletions
@ -0,0 +1,425 @@ |
|||
// Copyright 2009 the V8 project authors. All rights reserved.
|
|||
// Redistribution and use in source and binary forms, with or without
|
|||
// modification, are permitted provided that the following conditions are
|
|||
// met:
|
|||
//
|
|||
// * Redistributions of source code must retain the above copyright
|
|||
// notice, this list of conditions and the following disclaimer.
|
|||
// * Redistributions in binary form must reproduce the above
|
|||
// copyright notice, this list of conditions and the following
|
|||
// disclaimer in the documentation and/or other materials provided
|
|||
// with the distribution.
|
|||
// * Neither the name of Google Inc. nor the names of its
|
|||
// contributors may be used to endorse or promote products derived
|
|||
// from this software without specific prior written permission.
|
|||
//
|
|||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|||
#include <v8.h> |
|||
#include <v8-debug.h> |
|||
#include <fcntl.h> |
|||
#include <string.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
|
|||
/**
|
|||
* This sample program should demonstrate certain aspects of debugging |
|||
* standalone V8-based application. |
|||
* |
|||
* The program reads input stream, processes it line by line and print |
|||
* the result to output. The actual processing is done by custom JavaScript |
|||
* script. The script is specified with command line parameters. |
|||
* |
|||
* The main cycle of the program will sequentially read lines from standard |
|||
* input, process them and print to standard output until input closes. |
|||
* There are 2 possible configuration in regard to main cycle. |
|||
* |
|||
* 1. The main cycle is on C++ side. Program should be run with |
|||
* --main-cycle-in-cpp option. Script must declare a function named |
|||
* "ProcessLine". The main cycle in C++ reads lines and calls this function |
|||
* for processing every time. This is a sample script: |
|||
|
|||
function ProcessLine(input_line) { |
|||
return ">>>" + input_line + "<<<"; |
|||
} |
|||
|
|||
* |
|||
* 2. The main cycle is in JavaScript. Program should be run with |
|||
* --main-cycle-in-js option. Script gets run one time at all and gets |
|||
* API of 2 global functions: "read_line" and "print". It should read input |
|||
* and print converted lines to output itself. This a sample script: |
|||
|
|||
while (true) { |
|||
var line = read_line(); |
|||
if (!line) { |
|||
break; |
|||
} |
|||
var res = line + " | " + line; |
|||
print(res); |
|||
} |
|||
|
|||
* |
|||
* When run with "-p" argument, the program starts V8 Debugger Agent and |
|||
* allows remote debugger to attach and debug JavaScript code. |
|||
* |
|||
* Interesting aspects: |
|||
* 1. Wait for remote debugger to attach |
|||
* Normally the program compiles custom script and immediately runs it. |
|||
* If programmer needs to debug script from the very beginning, he should |
|||
* run this sample program with "--wait-for-connection" command line parameter. |
|||
* This way V8 will suspend on the first statement and wait for |
|||
* debugger to attach. |
|||
* |
|||
* 2. Unresponsive V8 |
|||
* V8 Debugger Agent holds a connection with remote debugger, but it does |
|||
* respond only when V8 is running some script. In particular, when this program |
|||
* is waiting for input, all requests from debugger get deferred until V8 |
|||
* is called again. See how "--callback" command-line parameter in this sample |
|||
* fixes this issue. |
|||
*/ |
|||
|
|||
enum MainCycleType { |
|||
CycleInCpp, |
|||
CycleInJs |
|||
}; |
|||
|
|||
const char* ToCString(const v8::String::Utf8Value& value); |
|||
void ReportException(v8::TryCatch* handler); |
|||
v8::Handle<v8::String> ReadFile(const char* name); |
|||
v8::Handle<v8::String> ReadLine(); |
|||
|
|||
v8::Handle<v8::Value> Print(const v8::Arguments& args); |
|||
v8::Handle<v8::Value> ReadLine(const v8::Arguments& args); |
|||
bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, |
|||
bool report_exceptions); |
|||
|
|||
v8::Persistent<v8::Context> debug_message_context; |
|||
|
|||
|
|||
void DispatchDebugMessages() { |
|||
// We are in some random thread. We should already have v8::Locker acquired
|
|||
// (we requested this when registered this callback). We was called
|
|||
// because new debug messages arrived; they may have already been processed,
|
|||
// but we shouldn't worry about this.
|
|||
//
|
|||
// All we have to do is to set context and call ProcessDebugMessages.
|
|||
//
|
|||
// We should decide which V8 context to use here. This is important for
|
|||
// "evaluate" command, because it must be executed some context.
|
|||
// In our sample we have only one context, so there is nothing really to
|
|||
// think about.
|
|||
v8::Context::Scope scope(debug_message_context); |
|||
|
|||
v8::Debug::ProcessDebugMessages(); |
|||
} |
|||
|
|||
|
|||
int RunMain(int argc, char* argv[]) { |
|||
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
|||
v8::HandleScope handle_scope; |
|||
|
|||
v8::Handle<v8::String> script_source(NULL); |
|||
v8::Handle<v8::Value> script_name(NULL); |
|||
int script_param_counter = 0; |
|||
|
|||
int port_number = -1; |
|||
bool wait_for_connection = false; |
|||
bool support_callback = false; |
|||
MainCycleType cycle_type = CycleInCpp; |
|||
|
|||
for (int i = 1; i < argc; i++) { |
|||
const char* str = argv[i]; |
|||
if (strcmp(str, "-f") == 0) { |
|||
// Ignore any -f flags for compatibility with the other stand-
|
|||
// alone JavaScript engines.
|
|||
continue; |
|||
} else if (strcmp(str, "--callback") == 0) { |
|||
support_callback = true; |
|||
} else if (strcmp(str, "--wait-for-connection") == 0) { |
|||
wait_for_connection = true; |
|||
} else if (strcmp(str, "--main-cycle-in-cpp") == 0) { |
|||
cycle_type = CycleInCpp; |
|||
} else if (strcmp(str, "--main-cycle-in-js") == 0) { |
|||
cycle_type = CycleInJs; |
|||
} else if (strcmp(str, "-p") == 0 && i + 1 < argc) { |
|||
port_number = atoi(argv[i + 1]); |
|||
i++; |
|||
} else if (strncmp(str, "--", 2) == 0) { |
|||
printf("Warning: unknown flag %s.\nTry --help for options\n", str); |
|||
} else if (strcmp(str, "-e") == 0 && i + 1 < argc) { |
|||
script_source = v8::String::New(argv[i + 1]); |
|||
script_name = v8::String::New("unnamed"); |
|||
i++; |
|||
script_param_counter++; |
|||
} else { |
|||
// Use argument as a name of file to load.
|
|||
script_source = ReadFile(str); |
|||
script_name = v8::String::New(str); |
|||
if (script_source.IsEmpty()) { |
|||
printf("Error reading '%s'\n", str); |
|||
return 1; |
|||
} |
|||
script_param_counter++; |
|||
} |
|||
} |
|||
|
|||
if (script_param_counter == 0) { |
|||
printf("Script is not specified\n"); |
|||
return 1; |
|||
} |
|||
if (script_param_counter != 1) { |
|||
printf("Only one script may be specified\n"); |
|||
return 1; |
|||
} |
|||
|
|||
// Create a template for the global object.
|
|||
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); |
|||
|
|||
// Bind the global 'print' function to the C++ Print callback.
|
|||
global->Set(v8::String::New("print"), v8::FunctionTemplate::New(Print)); |
|||
|
|||
if (cycle_type == CycleInJs) { |
|||
// Bind the global 'read_line' function to the C++ Print callback.
|
|||
global->Set(v8::String::New("read_line"), |
|||
v8::FunctionTemplate::New(ReadLine)); |
|||
} |
|||
|
|||
// Create a new execution environment containing the built-in
|
|||
// functions
|
|||
v8::Handle<v8::Context> context = v8::Context::New(NULL, global); |
|||
debug_message_context = v8::Persistent<v8::Context>::New(context); |
|||
|
|||
|
|||
// Enter the newly created execution environment.
|
|||
v8::Context::Scope context_scope(context); |
|||
|
|||
v8::Locker locker; |
|||
|
|||
if (support_callback) { |
|||
v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true); |
|||
} |
|||
|
|||
if (port_number != -1) { |
|||
const char* auto_break_param = "--debugger_auto_break"; |
|||
v8::V8::SetFlagsFromString(auto_break_param, strlen(auto_break_param)); |
|||
v8::Debug::EnableAgent("lineprocessor", port_number, wait_for_connection); |
|||
} |
|||
|
|||
bool report_exceptions = true; |
|||
|
|||
v8::Handle<v8::Script> script; |
|||
{ |
|||
// Compile script in try/catch context.
|
|||
v8::TryCatch try_catch; |
|||
script = v8::Script::Compile(script_source, script_name); |
|||
if (script.IsEmpty()) { |
|||
// Print errors that happened during compilation.
|
|||
if (report_exceptions) |
|||
ReportException(&try_catch); |
|||
return 1; |
|||
} |
|||
} |
|||
|
|||
{ |
|||
v8::TryCatch try_catch; |
|||
|
|||
script->Run(); |
|||
if (try_catch.HasCaught()) { |
|||
if (report_exceptions) |
|||
ReportException(&try_catch); |
|||
return 1; |
|||
} |
|||
} |
|||
|
|||
if (cycle_type == CycleInCpp) { |
|||
bool res = RunCppCycle(script, v8::Context::GetCurrent(), |
|||
report_exceptions); |
|||
return !res; |
|||
} else { |
|||
// All is already done.
|
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
|
|||
bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, |
|||
bool report_exceptions) { |
|||
v8::Locker lock; |
|||
|
|||
v8::Handle<v8::String> fun_name = v8::String::New("ProcessLine"); |
|||
v8::Handle<v8::Value> process_val = |
|||
v8::Context::GetCurrent()->Global()->Get(fun_name); |
|||
|
|||
// If there is no Process function, or if it is not a function,
|
|||
// bail out
|
|||
if (!process_val->IsFunction()) { |
|||
printf("Error: Script does not declare 'ProcessLine' global function.\n"); |
|||
return 1; |
|||
} |
|||
|
|||
// It is a function; cast it to a Function
|
|||
v8::Handle<v8::Function> process_fun = |
|||
v8::Handle<v8::Function>::Cast(process_val); |
|||
|
|||
|
|||
while (!feof(stdin)) { |
|||
v8::HandleScope handle_scope; |
|||
|
|||
v8::Handle<v8::String> input_line = ReadLine(); |
|||
if (input_line == v8::Undefined()) { |
|||
continue; |
|||
} |
|||
|
|||
const int argc = 1; |
|||
v8::Handle<v8::Value> argv[argc] = { input_line }; |
|||
|
|||
v8::Handle<v8::Value> result; |
|||
{ |
|||
v8::TryCatch try_catch; |
|||
result = process_fun->Call(v8::Context::GetCurrent()->Global(), |
|||
argc, argv); |
|||
if (try_catch.HasCaught()) { |
|||
if (report_exceptions) |
|||
ReportException(&try_catch); |
|||
return false; |
|||
} |
|||
} |
|||
v8::String::Utf8Value str(result); |
|||
const char* cstr = ToCString(str); |
|||
printf("%s\n", cstr); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
int main(int argc, char* argv[]) { |
|||
int result = RunMain(argc, argv); |
|||
v8::V8::Dispose(); |
|||
return result; |
|||
} |
|||
|
|||
|
|||
// Extracts a C string from a V8 Utf8Value.
|
|||
const char* ToCString(const v8::String::Utf8Value& value) { |
|||
return *value ? *value : "<string conversion failed>"; |
|||
} |
|||
|
|||
|
|||
// Reads a file into a v8 string.
|
|||
v8::Handle<v8::String> ReadFile(const char* name) { |
|||
FILE* file = fopen(name, "rb"); |
|||
if (file == NULL) return v8::Handle<v8::String>(); |
|||
|
|||
fseek(file, 0, SEEK_END); |
|||
int size = ftell(file); |
|||
rewind(file); |
|||
|
|||
char* chars = new char[size + 1]; |
|||
chars[size] = '\0'; |
|||
for (int i = 0; i < size;) { |
|||
int read = fread(&chars[i], 1, size - i, file); |
|||
i += read; |
|||
} |
|||
fclose(file); |
|||
v8::Handle<v8::String> result = v8::String::New(chars, size); |
|||
delete[] chars; |
|||
return result; |
|||
} |
|||
|
|||
|
|||
void ReportException(v8::TryCatch* try_catch) { |
|||
v8::HandleScope handle_scope; |
|||
v8::String::Utf8Value exception(try_catch->Exception()); |
|||
const char* exception_string = ToCString(exception); |
|||
v8::Handle<v8::Message> message = try_catch->Message(); |
|||
if (message.IsEmpty()) { |
|||
// V8 didn't provide any extra information about this error; just
|
|||
// print the exception.
|
|||
printf("%s\n", exception_string); |
|||
} else { |
|||
// Print (filename):(line number): (message).
|
|||
v8::String::Utf8Value filename(message->GetScriptResourceName()); |
|||
const char* filename_string = ToCString(filename); |
|||
int linenum = message->GetLineNumber(); |
|||
printf("%s:%i: %s\n", filename_string, linenum, exception_string); |
|||
// Print line of source code.
|
|||
v8::String::Utf8Value sourceline(message->GetSourceLine()); |
|||
const char* sourceline_string = ToCString(sourceline); |
|||
printf("%s\n", sourceline_string); |
|||
// Print wavy underline (GetUnderline is deprecated).
|
|||
int start = message->GetStartColumn(); |
|||
for (int i = 0; i < start; i++) { |
|||
printf(" "); |
|||
} |
|||
int end = message->GetEndColumn(); |
|||
for (int i = start; i < end; i++) { |
|||
printf("^"); |
|||
} |
|||
printf("\n"); |
|||
} |
|||
} |
|||
|
|||
|
|||
// The callback that is invoked by v8 whenever the JavaScript 'print'
|
|||
// function is called. Prints its arguments on stdout separated by
|
|||
// spaces and ending with a newline.
|
|||
v8::Handle<v8::Value> Print(const v8::Arguments& args) { |
|||
bool first = true; |
|||
for (int i = 0; i < args.Length(); i++) { |
|||
v8::HandleScope handle_scope; |
|||
if (first) { |
|||
first = false; |
|||
} else { |
|||
printf(" "); |
|||
} |
|||
v8::String::Utf8Value str(args[i]); |
|||
const char* cstr = ToCString(str); |
|||
printf("%s", cstr); |
|||
} |
|||
printf("\n"); |
|||
fflush(stdout); |
|||
return v8::Undefined(); |
|||
} |
|||
|
|||
|
|||
// The callback that is invoked by v8 whenever the JavaScript 'read_line'
|
|||
// function is called. Reads a string from standard input and returns.
|
|||
v8::Handle<v8::Value> ReadLine(const v8::Arguments& args) { |
|||
if (args.Length() > 0) { |
|||
return v8::ThrowException(v8::String::New("Unexpected arguments")); |
|||
} |
|||
return ReadLine(); |
|||
} |
|||
|
|||
v8::Handle<v8::String> ReadLine() { |
|||
const int kBufferSize = 1024 + 1; |
|||
char buffer[kBufferSize]; |
|||
|
|||
char* res; |
|||
{ |
|||
v8::Unlocker unlocker; |
|||
res = fgets(buffer, kBufferSize, stdin); |
|||
} |
|||
if (res == NULL) { |
|||
v8::Handle<v8::Primitive> t = v8::Undefined(); |
|||
return reinterpret_cast<v8::Handle<v8::String>&>(t); |
|||
} |
|||
// remove newline char
|
|||
for (char* pos = buffer; *pos != '\0'; pos++) { |
|||
if (*pos == '\n') { |
|||
*pos = '\0'; |
|||
break; |
|||
} |
|||
} |
|||
return v8::String::New(buffer); |
|||
} |
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,267 @@ |
|||
// Copyright 2010 the V8 project authors. All rights reserved.
|
|||
// Redistribution and use in source and binary forms, with or without
|
|||
// modification, are permitted provided that the following conditions are
|
|||
// met:
|
|||
//
|
|||
// * Redistributions of source code must retain the above copyright
|
|||
// notice, this list of conditions and the following disclaimer.
|
|||
// * Redistributions in binary form must reproduce the above
|
|||
// copyright notice, this list of conditions and the following
|
|||
// disclaimer in the documentation and/or other materials provided
|
|||
// with the distribution.
|
|||
// * Neither the name of Google Inc. nor the names of its
|
|||
// contributors may be used to endorse or promote products derived
|
|||
// from this software without specific prior written permission.
|
|||
//
|
|||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|||
#include "v8.h" |
|||
|
|||
#include "data-flow.h" |
|||
|
|||
namespace v8 { |
|||
namespace internal { |
|||
|
|||
|
|||
void AstLabeler::Label(FunctionLiteral* fun) { |
|||
VisitStatements(fun->body()); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitStatements(ZoneList<Statement*>* stmts) { |
|||
for (int i = 0, len = stmts->length(); i < len; i++) { |
|||
Visit(stmts->at(i)); |
|||
} |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitDeclarations(ZoneList<Declaration*>* decls) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitBlock(Block* stmt) { |
|||
VisitStatements(stmt->statements()); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitExpressionStatement( |
|||
ExpressionStatement* stmt) { |
|||
Visit(stmt->expression()); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitEmptyStatement(EmptyStatement* stmt) { |
|||
// Do nothing.
|
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitIfStatement(IfStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitContinueStatement(ContinueStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitBreakStatement(BreakStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitReturnStatement(ReturnStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitWithEnterStatement( |
|||
WithEnterStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitWithExitStatement(WithExitStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitSwitchStatement(SwitchStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitDoWhileStatement(DoWhileStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitWhileStatement(WhileStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitForStatement(ForStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitForInStatement(ForInStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitTryCatchStatement(TryCatchStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitTryFinallyStatement( |
|||
TryFinallyStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitDebuggerStatement( |
|||
DebuggerStatement* stmt) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitFunctionLiteral(FunctionLiteral* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitFunctionBoilerplateLiteral( |
|||
FunctionBoilerplateLiteral* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitConditional(Conditional* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitSlot(Slot* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitVariableProxy(VariableProxy* expr) { |
|||
expr->set_num(next_number_++); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitLiteral(Literal* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitRegExpLiteral(RegExpLiteral* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitObjectLiteral(ObjectLiteral* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitArrayLiteral(ArrayLiteral* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitCatchExtensionObject( |
|||
CatchExtensionObject* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitAssignment(Assignment* expr) { |
|||
Property* prop = expr->target()->AsProperty(); |
|||
ASSERT(prop != NULL); |
|||
if (prop != NULL) { |
|||
ASSERT(prop->key()->IsPropertyName()); |
|||
VariableProxy* proxy = prop->obj()->AsVariableProxy(); |
|||
if (proxy != NULL && proxy->var()->is_this()) { |
|||
has_this_properties_ = true; |
|||
} else { |
|||
Visit(prop->obj()); |
|||
} |
|||
} |
|||
Visit(expr->value()); |
|||
expr->set_num(next_number_++); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitThrow(Throw* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitProperty(Property* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitCall(Call* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitCallNew(CallNew* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitCallRuntime(CallRuntime* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitUnaryOperation(UnaryOperation* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitCountOperation(CountOperation* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitBinaryOperation(BinaryOperation* expr) { |
|||
Visit(expr->left()); |
|||
Visit(expr->right()); |
|||
expr->set_num(next_number_++); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitCompareOperation(CompareOperation* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitThisFunction(ThisFunction* expr) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
|
|||
void AstLabeler::VisitDeclaration(Declaration* decl) { |
|||
UNREACHABLE(); |
|||
} |
|||
|
|||
} } // namespace v8::internal
|
@ -0,0 +1,67 @@ |
|||
// Copyright 2010 the V8 project authors. All rights reserved.
|
|||
// Redistribution and use in source and binary forms, with or without
|
|||
// modification, are permitted provided that the following conditions are
|
|||
// met:
|
|||
//
|
|||
// * Redistributions of source code must retain the above copyright
|
|||
// notice, this list of conditions and the following disclaimer.
|
|||
// * Redistributions in binary form must reproduce the above
|
|||
// copyright notice, this list of conditions and the following
|
|||
// disclaimer in the documentation and/or other materials provided
|
|||
// with the distribution.
|
|||
// * Neither the name of Google Inc. nor the names of its
|
|||
// contributors may be used to endorse or promote products derived
|
|||
// from this software without specific prior written permission.
|
|||
//
|
|||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|||
#ifndef V8_DATAFLOW_H_ |
|||
#define V8_DATAFLOW_H_ |
|||
|
|||
#include "ast.h" |
|||
#include "scopes.h" |
|||
|
|||
namespace v8 { |
|||
namespace internal { |
|||
|
|||
// This class is used to number all expressions in the AST according to
|
|||
// their evaluation order (post-order left-to-right traversal).
|
|||
class AstLabeler: public AstVisitor { |
|||
public: |
|||
AstLabeler() : next_number_(0), has_this_properties_(false) {} |
|||
|
|||
void Label(FunctionLiteral* fun); |
|||
|
|||
bool has_this_properties() { return has_this_properties_; } |
|||
|
|||
private: |
|||
void VisitDeclarations(ZoneList<Declaration*>* decls); |
|||
void VisitStatements(ZoneList<Statement*>* stmts); |
|||
|
|||
// AST node visit functions.
|
|||
#define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
|||
AST_NODE_LIST(DECLARE_VISIT) |
|||
#undef DECLARE_VISIT |
|||
|
|||
// Traversal number for labelling AST nodes.
|
|||
int next_number_; |
|||
|
|||
bool has_this_properties_; |
|||
|
|||
DISALLOW_COPY_AND_ASSIGN(AstLabeler); |
|||
}; |
|||
|
|||
|
|||
} } // namespace v8::internal
|
|||
|
|||
#endif // V8_DATAFLOW_H_
|
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,452 @@ |
|||
// Copyright 2009 the V8 project authors. All rights reserved.
|
|||
// Redistribution and use in source and binary forms, with or without
|
|||
// modification, are permitted provided that the following conditions are
|
|||
// met:
|
|||
//
|
|||
// * Redistributions of source code must retain the above copyright
|
|||
// notice, this list of conditions and the following disclaimer.
|
|||
// * Redistributions in binary form must reproduce the above
|
|||
// copyright notice, this list of conditions and the following
|
|||
// disclaimer in the documentation and/or other materials provided
|
|||
// with the distribution.
|
|||
// * Neither the name of Google Inc. nor the names of its
|
|||
// contributors may be used to endorse or promote products derived
|
|||
// from this software without specific prior written permission.
|
|||
//
|
|||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|||
#ifndef V8_FULL_CODEGEN_H_ |
|||
#define V8_FULL_CODEGEN_H_ |
|||
|
|||
#include "v8.h" |
|||
|
|||
#include "ast.h" |
|||
|
|||
namespace v8 { |
|||
namespace internal { |
|||
|
|||
class FullCodeGenSyntaxChecker: public AstVisitor { |
|||
public: |
|||
FullCodeGenSyntaxChecker() : has_supported_syntax_(true) {} |
|||
|
|||
void Check(FunctionLiteral* fun); |
|||
|
|||
bool has_supported_syntax() { return has_supported_syntax_; } |
|||
|
|||
private: |
|||
void VisitDeclarations(ZoneList<Declaration*>* decls); |
|||
void VisitStatements(ZoneList<Statement*>* stmts); |
|||
|
|||
// AST node visit functions.
|
|||
#define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
|||
AST_NODE_LIST(DECLARE_VISIT) |
|||
#undef DECLARE_VISIT |
|||
|
|||
bool has_supported_syntax_; |
|||
|
|||
DISALLOW_COPY_AND_ASSIGN(FullCodeGenSyntaxChecker); |
|||
}; |
|||
|
|||
|
|||
// -----------------------------------------------------------------------------
|
|||
// Full code generator.
|
|||
|
|||
class FullCodeGenerator: public AstVisitor { |
|||
public: |
|||
enum Mode { |
|||
PRIMARY, |
|||
SECONDARY |
|||
}; |
|||
|
|||
FullCodeGenerator(MacroAssembler* masm, Handle<Script> script, bool is_eval) |
|||
: masm_(masm), |
|||
script_(script), |
|||
is_eval_(is_eval), |
|||
function_(NULL), |
|||
nesting_stack_(NULL), |
|||
loop_depth_(0), |
|||
location_(kStack), |
|||
true_label_(NULL), |
|||
false_label_(NULL) { |
|||
} |
|||
|
|||
static Handle<Code> MakeCode(FunctionLiteral* fun, |
|||
Handle<Script> script, |
|||
bool is_eval); |
|||
|
|||
void Generate(FunctionLiteral* fun, Mode mode); |
|||
|
|||
private: |
|||
class Breakable; |
|||
class Iteration; |
|||
class TryCatch; |
|||
class TryFinally; |
|||
class Finally; |
|||
class ForIn; |
|||
|
|||
class NestedStatement BASE_EMBEDDED { |
|||
public: |
|||
explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { |
|||
// Link into codegen's nesting stack.
|
|||
previous_ = codegen->nesting_stack_; |
|||
codegen->nesting_stack_ = this; |
|||
} |
|||
virtual ~NestedStatement() { |
|||
// Unlink from codegen's nesting stack.
|
|||
ASSERT_EQ(this, codegen_->nesting_stack_); |
|||
codegen_->nesting_stack_ = previous_; |
|||
} |
|||
|
|||
virtual Breakable* AsBreakable() { return NULL; } |
|||
virtual Iteration* AsIteration() { return NULL; } |
|||
virtual TryCatch* AsTryCatch() { return NULL; } |
|||
virtual TryFinally* AsTryFinally() { return NULL; } |
|||
virtual Finally* AsFinally() { return NULL; } |
|||
virtual ForIn* AsForIn() { return NULL; } |
|||
|
|||
virtual bool IsContinueTarget(Statement* target) { return false; } |
|||
virtual bool IsBreakTarget(Statement* target) { return false; } |
|||
|
|||
// Generate code to leave the nested statement. This includes
|
|||
// cleaning up any stack elements in use and restoring the
|
|||
// stack to the expectations of the surrounding statements.
|
|||
// Takes a number of stack elements currently on top of the
|
|||
// nested statement's stack, and returns a number of stack
|
|||
// elements left on top of the surrounding statement's stack.
|
|||
// The generated code must preserve the result register (which
|
|||
// contains the value in case of a return).
|
|||
virtual int Exit(int stack_depth) { |
|||
// Default implementation for the case where there is
|
|||
// nothing to clean up.
|
|||
return stack_depth; |
|||
} |
|||
NestedStatement* outer() { return previous_; } |
|||
protected: |
|||
MacroAssembler* masm() { return codegen_->masm(); } |
|||
private: |
|||
FullCodeGenerator* codegen_; |
|||
NestedStatement* previous_; |
|||
DISALLOW_COPY_AND_ASSIGN(NestedStatement); |
|||
}; |
|||
|
|||
class Breakable : public NestedStatement { |
|||
public: |
|||
Breakable(FullCodeGenerator* codegen, |
|||
BreakableStatement* break_target) |
|||
: NestedStatement(codegen), |
|||
target_(break_target) {} |
|||
virtual ~Breakable() {} |
|||
virtual Breakable* AsBreakable() { return this; } |
|||
virtual bool IsBreakTarget(Statement* statement) { |
|||
return target_ == statement; |
|||
} |
|||
BreakableStatement* statement() { return target_; } |
|||
Label* break_target() { return &break_target_label_; } |
|||
private: |
|||
BreakableStatement* target_; |
|||
Label break_target_label_; |
|||
DISALLOW_COPY_AND_ASSIGN(Breakable); |
|||
}; |
|||
|
|||
class Iteration : public Breakable { |
|||
public: |
|||
Iteration(FullCodeGenerator* codegen, |
|||
IterationStatement* iteration_statement) |
|||
: Breakable(codegen, iteration_statement) {} |
|||
virtual ~Iteration() {} |
|||
virtual Iteration* AsIteration() { return this; } |
|||
virtual bool IsContinueTarget(Statement* statement) { |
|||
return this->statement() == statement; |
|||
} |
|||
Label* continue_target() { return &continue_target_label_; } |
|||
private: |
|||
Label continue_target_label_; |
|||
DISALLOW_COPY_AND_ASSIGN(Iteration); |
|||
}; |
|||
|
|||
// The environment inside the try block of a try/catch statement.
|
|||
class TryCatch : public NestedStatement { |
|||
public: |
|||
explicit TryCatch(FullCodeGenerator* codegen, Label* catch_entry) |
|||
: NestedStatement(codegen), catch_entry_(catch_entry) { } |
|||
virtual ~TryCatch() {} |
|||
virtual TryCatch* AsTryCatch() { return this; } |
|||
Label* catch_entry() { return catch_entry_; } |
|||
virtual int Exit(int stack_depth); |
|||
private: |
|||
Label* catch_entry_; |
|||
DISALLOW_COPY_AND_ASSIGN(TryCatch); |
|||
}; |
|||
|
|||
// The environment inside the try block of a try/finally statement.
|
|||
class TryFinally : public NestedStatement { |
|||
public: |
|||
explicit TryFinally(FullCodeGenerator* codegen, Label* finally_entry) |
|||
: NestedStatement(codegen), finally_entry_(finally_entry) { } |
|||
virtual ~TryFinally() {} |
|||
virtual TryFinally* AsTryFinally() { return this; } |
|||
Label* finally_entry() { return finally_entry_; } |
|||
virtual int Exit(int stack_depth); |
|||
private: |
|||
Label* finally_entry_; |
|||
DISALLOW_COPY_AND_ASSIGN(TryFinally); |
|||
}; |
|||
|
|||
// A FinallyEnvironment represents being inside a finally block.
|
|||
// Abnormal termination of the finally block needs to clean up
|
|||
// the block's parameters from the stack.
|
|||
class Finally : public NestedStatement { |
|||
public: |
|||
explicit Finally(FullCodeGenerator* codegen) : NestedStatement(codegen) { } |
|||
virtual ~Finally() {} |
|||
virtual Finally* AsFinally() { return this; } |
|||
virtual int Exit(int stack_depth) { |
|||
return stack_depth + kFinallyStackElementCount; |
|||
} |
|||
private: |
|||
// Number of extra stack slots occupied during a finally block.
|
|||
static const int kFinallyStackElementCount = 2; |
|||
DISALLOW_COPY_AND_ASSIGN(Finally); |
|||
}; |
|||
|
|||
// A ForInEnvironment represents being inside a for-in loop.
|
|||
// Abnormal termination of the for-in block needs to clean up
|
|||
// the block's temporary storage from the stack.
|
|||
class ForIn : public Iteration { |
|||
public: |
|||
ForIn(FullCodeGenerator* codegen, |
|||
ForInStatement* statement) |
|||
: Iteration(codegen, statement) { } |
|||
virtual ~ForIn() {} |
|||
virtual ForIn* AsForIn() { return this; } |
|||
virtual int Exit(int stack_depth) { |
|||
return stack_depth + kForInStackElementCount; |
|||
} |
|||
private: |
|||
// TODO(lrn): Check that this value is correct when implementing
|
|||
// for-in.
|
|||
static const int kForInStackElementCount = 5; |
|||
DISALLOW_COPY_AND_ASSIGN(ForIn); |
|||
}; |
|||
|
|||
enum Location { |
|||
kAccumulator, |
|||
kStack |
|||
}; |
|||
|
|||
int SlotOffset(Slot* slot); |
|||
|
|||
// Emit code to convert a pure value (in a register, slot, as a literal,
|
|||
// or on top of the stack) into the result expected according to an
|
|||
// expression context.
|
|||
void Apply(Expression::Context context, Register reg); |
|||
|
|||
// Slot cannot have type Slot::LOOKUP.
|
|||
void Apply(Expression::Context context, Slot* slot); |
|||
|
|||
void Apply(Expression::Context context, Literal* lit); |
|||
void ApplyTOS(Expression::Context context); |
|||
|
|||
// Emit code to discard count elements from the top of stack, then convert
|
|||
// a pure value into the result expected according to an expression
|
|||
// context.
|
|||
void DropAndApply(int count, Expression::Context context, Register reg); |
|||
|
|||
// Emit code to convert pure control flow to a pair of labels into the
|
|||
// result expected according to an expression context.
|
|||
void Apply(Expression::Context context, |
|||
Label* materialize_true, |
|||
Label* materialize_false); |
|||
|
|||
// Helper function to convert a pure value into a test context. The value
|
|||
// is expected on the stack or the accumulator, depending on the platform.
|
|||
// See the platform-specific implementation for details.
|
|||
void DoTest(Expression::Context context); |
|||
|
|||
void Move(Slot* dst, Register source, Register scratch1, Register scratch2); |
|||
void Move(Register dst, Slot* source); |
|||
|
|||
// Return an operand used to read/write to a known (ie, non-LOOKUP) slot.
|
|||
// May emit code to traverse the context chain, destroying the scratch
|
|||
// register.
|
|||
MemOperand EmitSlotSearch(Slot* slot, Register scratch); |
|||
|
|||
void VisitForEffect(Expression* expr) { |
|||
Expression::Context saved_context = context_; |
|||
context_ = Expression::kEffect; |
|||
Visit(expr); |
|||
context_ = saved_context; |
|||
} |
|||
|
|||
void VisitForValue(Expression* expr, Location where) { |
|||
Expression::Context saved_context = context_; |
|||
Location saved_location = location_; |
|||
context_ = Expression::kValue; |
|||
location_ = where; |
|||
Visit(expr); |
|||
context_ = saved_context; |
|||
location_ = saved_location; |
|||
} |
|||
|
|||
void VisitForControl(Expression* expr, Label* if_true, Label* if_false) { |
|||
Expression::Context saved_context = context_; |
|||
Label* saved_true = true_label_; |
|||
Label* saved_false = false_label_; |
|||
context_ = Expression::kTest; |
|||
true_label_ = if_true; |
|||
false_label_ = if_false; |
|||
Visit(expr); |
|||
context_ = saved_context; |
|||
true_label_ = saved_true; |
|||
false_label_ = saved_false; |
|||
} |
|||
|
|||
void VisitForValueControl(Expression* expr, |
|||
Location where, |
|||
Label* if_true, |
|||
Label* if_false) { |
|||
Expression::Context saved_context = context_; |
|||
Location saved_location = location_; |
|||
Label* saved_true = true_label_; |
|||
Label* saved_false = false_label_; |
|||
context_ = Expression::kValueTest; |
|||
location_ = where; |
|||
true_label_ = if_true; |
|||
false_label_ = if_false; |
|||
Visit(expr); |
|||
context_ = saved_context; |
|||
location_ = saved_location; |
|||
true_label_ = saved_true; |
|||
false_label_ = saved_false; |
|||
} |
|||
|
|||
void VisitForControlValue(Expression* expr, |
|||
Location where, |
|||
Label* if_true, |
|||
Label* if_false) { |
|||
Expression::Context saved_context = context_; |
|||
Location saved_location = location_; |
|||
Label* saved_true = true_label_; |
|||
Label* saved_false = false_label_; |
|||
context_ = Expression::kTestValue; |
|||
location_ = where; |
|||
true_label_ = if_true; |
|||
false_label_ = if_false; |
|||
Visit(expr); |
|||
context_ = saved_context; |
|||
location_ = saved_location; |
|||
true_label_ = saved_true; |
|||
false_label_ = saved_false; |
|||
} |
|||
|
|||
void VisitDeclarations(ZoneList<Declaration*>* declarations); |
|||
void DeclareGlobals(Handle<FixedArray> pairs); |
|||
|
|||
// Platform-specific return sequence
|
|||
void EmitReturnSequence(int position); |
|||
|
|||
// Platform-specific code sequences for calls
|
|||
void EmitCallWithStub(Call* expr); |
|||
void EmitCallWithIC(Call* expr, Handle<Object> name, RelocInfo::Mode mode); |
|||
|
|||
// Platform-specific code for loading variables.
|
|||
void EmitVariableLoad(Variable* expr, Expression::Context context); |
|||
|
|||
// Platform-specific support for compiling assignments.
|
|||
|
|||
// Load a value from a named property.
|
|||
// The receiver is left on the stack by the IC.
|
|||
void EmitNamedPropertyLoad(Property* expr); |
|||
|
|||
// Load a value from a keyed property.
|
|||
// The receiver and the key is left on the stack by the IC.
|
|||
void EmitKeyedPropertyLoad(Property* expr); |
|||
|
|||
// Apply the compound assignment operator. Expects the left operand on top
|
|||
// of the stack and the right one in the accumulator.
|
|||
void EmitBinaryOp(Token::Value op, Expression::Context context); |
|||
|
|||
// Complete a variable assignment. The right-hand-side value is expected
|
|||
// in the accumulator.
|
|||
void EmitVariableAssignment(Variable* var, Expression::Context context); |
|||
|
|||
// Complete a named property assignment. The receiver is expected on top
|
|||
// of the stack and the right-hand-side value in the accumulator.
|
|||
void EmitNamedPropertyAssignment(Assignment* expr); |
|||
|
|||
// Complete a keyed property assignment. The receiver and key are
|
|||
// expected on top of the stack and the right-hand-side value in the
|
|||
// accumulator.
|
|||
void EmitKeyedPropertyAssignment(Assignment* expr); |
|||
|
|||
void SetFunctionPosition(FunctionLiteral* fun); |
|||
void SetReturnPosition(FunctionLiteral* fun); |
|||
void SetStatementPosition(Statement* stmt); |
|||
void SetStatementPosition(int pos); |
|||
void SetSourcePosition(int pos); |
|||
|
|||
// Non-local control flow support.
|
|||
void EnterFinallyBlock(); |
|||
void ExitFinallyBlock(); |
|||
|
|||
// Loop nesting counter.
|
|||
int loop_depth() { return loop_depth_; } |
|||
void increment_loop_depth() { loop_depth_++; } |
|||
void decrement_loop_depth() { |
|||
ASSERT(loop_depth_ > 0); |
|||
loop_depth_--; |
|||
} |
|||
|
|||
MacroAssembler* masm() { return masm_; } |
|||
static Register result_register(); |
|||
static Register context_register(); |
|||
|
|||
// Set fields in the stack frame. Offsets are the frame pointer relative
|
|||
// offsets defined in, e.g., StandardFrameConstants.
|
|||
void StoreToFrameField(int frame_offset, Register value); |
|||
|
|||
// Load a value from the current context. Indices are defined as an enum
|
|||
// in v8::internal::Context.
|
|||
void LoadContextField(Register dst, int context_index); |
|||
|
|||
// AST node visit functions.
|
|||
#define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
|||
AST_NODE_LIST(DECLARE_VISIT) |
|||
#undef DECLARE_VISIT |
|||
// Handles the shortcutted logical binary operations in VisitBinaryOperation.
|
|||
void EmitLogicalOperation(BinaryOperation* expr); |
|||
|
|||
MacroAssembler* masm_; |
|||
Handle<Script> script_; |
|||
bool is_eval_; |
|||
|
|||
FunctionLiteral* function_; |
|||
|
|||
Label return_label_; |
|||
NestedStatement* nesting_stack_; |
|||
int loop_depth_; |
|||
|
|||
Expression::Context context_; |
|||
Location location_; |
|||
Label* true_label_; |
|||
Label* false_label_; |
|||
|
|||
friend class NestedStatement; |
|||
|
|||
DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
|||
}; |
|||
|
|||
|
|||
} } // namespace v8::internal
|
|||
|
|||
#endif // V8_FULL_CODEGEN_H_
|
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue