Minor bugfixes and optimizations.
Added command line debugger to D8 shell.
Fixed subtle bug that caused the wrong 'this' to be used when calling a caught function in a catch clause.
Inline array loads within loops directly in the code instead of
git-svn-id: http://v8.googlecode.com/svn/trunk@1031 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/codegen-arm.cc b/src/codegen-arm.cc
index 712a989..e0cae7f 100644
--- a/src/codegen-arm.cc
+++ b/src/codegen-arm.cc
@@ -1043,7 +1043,7 @@
}
// Record the position for debugging purposes.
- __ RecordPosition(position);
+ CodeForSourcePosition(position);
// Use the shared code stub to call the function.
CallFunctionStub call_function(args->length());
@@ -1074,7 +1074,7 @@
void CodeGenerator::VisitBlock(Block* node) {
Comment cmnt(masm_, "[ Block");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
node->set_break_stack_height(break_stack_height_);
VisitStatements(node->statements());
__ bind(node->break_target());
@@ -1094,6 +1094,7 @@
void CodeGenerator::VisitDeclaration(Declaration* node) {
Comment cmnt(masm_, "[ Declaration");
+ CodeForStatement(node);
Variable* var = node->proxy()->var();
ASSERT(var != NULL); // must have been resolved
Slot* slot = var->slot();
@@ -1159,7 +1160,7 @@
void CodeGenerator::VisitExpressionStatement(ExpressionStatement* node) {
Comment cmnt(masm_, "[ ExpressionStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
Expression* expression = node->expression();
expression->MarkAsStatement();
Load(expression);
@@ -1169,6 +1170,7 @@
void CodeGenerator::VisitEmptyStatement(EmptyStatement* node) {
Comment cmnt(masm_, "// EmptyStatement");
+ CodeForStatement(node);
// nothing to do
}
@@ -1180,7 +1182,7 @@
bool has_then_stm = node->HasThenStatement();
bool has_else_stm = node->HasElseStatement();
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
Label exit;
if (has_then_stm && has_else_stm) {
@@ -1245,7 +1247,7 @@
void CodeGenerator::VisitContinueStatement(ContinueStatement* node) {
Comment cmnt(masm_, "[ ContinueStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
CleanStack(break_stack_height_ - node->target()->break_stack_height());
__ b(node->target()->continue_target());
}
@@ -1253,7 +1255,7 @@
void CodeGenerator::VisitBreakStatement(BreakStatement* node) {
Comment cmnt(masm_, "[ BreakStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
CleanStack(break_stack_height_ - node->target()->break_stack_height());
__ b(node->target()->break_target());
}
@@ -1261,7 +1263,7 @@
void CodeGenerator::VisitReturnStatement(ReturnStatement* node) {
Comment cmnt(masm_, "[ ReturnStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
Load(node->expression());
// Move the function result into r0.
frame_->Pop(r0);
@@ -1272,9 +1274,13 @@
void CodeGenerator::VisitWithEnterStatement(WithEnterStatement* node) {
Comment cmnt(masm_, "[ WithEnterStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
Load(node->expression());
- __ CallRuntime(Runtime::kPushContext, 1);
+ if (node->is_catch_block()) {
+ __ CallRuntime(Runtime::kPushCatchContext, 1);
+ } else {
+ __ CallRuntime(Runtime::kPushContext, 1);
+ }
if (kDebug) {
Label verified_true;
__ cmp(r0, Operand(cp));
@@ -1289,6 +1295,7 @@
void CodeGenerator::VisitWithExitStatement(WithExitStatement* node) {
Comment cmnt(masm_, "[ WithExitStatement");
+ CodeForStatement(node);
// Pop context.
__ ldr(cp, ContextOperand(cp, Context::PREVIOUS_INDEX));
// Update context local.
@@ -1355,7 +1362,7 @@
void CodeGenerator::VisitSwitchStatement(SwitchStatement* node) {
Comment cmnt(masm_, "[ SwitchStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
node->set_break_stack_height(break_stack_height_);
Load(node->tag());
@@ -1423,7 +1430,7 @@
void CodeGenerator::VisitLoopStatement(LoopStatement* node) {
Comment cmnt(masm_, "[ LoopStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
node->set_break_stack_height(break_stack_height_);
// simple condition analysis
@@ -1463,7 +1470,7 @@
// Record source position of the statement as this code which is after the
// code for the body actually belongs to the loop statement and not the
// body.
- if (FLAG_debug_info) __ RecordPosition(node->statement_pos());
+ CodeForStatement(node);
ASSERT(node->type() == LoopStatement::FOR_LOOP);
Visit(node->next());
}
@@ -1495,7 +1502,7 @@
void CodeGenerator::VisitForInStatement(ForInStatement* node) {
Comment cmnt(masm_, "[ ForInStatement");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
// We keep stuff on the stack while the body is executing.
// Record it, so that a break/continue crossing this statement
@@ -1683,6 +1690,7 @@
void CodeGenerator::VisitTryCatch(TryCatch* node) {
Comment cmnt(masm_, "[ TryCatch");
+ CodeForStatement(node);
Label try_block, exit;
@@ -1779,6 +1787,7 @@
void CodeGenerator::VisitTryFinally(TryFinally* node) {
Comment cmnt(masm_, "[ TryFinally");
+ CodeForStatement(node);
// State: Used to keep track of reason for entering the finally
// block. Should probably be extended to hold information for
@@ -1920,7 +1929,7 @@
void CodeGenerator::VisitDebuggerStatement(DebuggerStatement* node) {
Comment cmnt(masm_, "[ DebuggerStatament");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
__ CallRuntime(Runtime::kDebugBreak, 0);
// Ignore the return value.
}
@@ -2228,7 +2237,7 @@
void CodeGenerator::VisitAssignment(Assignment* node) {
Comment cmnt(masm_, "[ Assignment");
- if (FLAG_debug_info) RecordStatementPosition(node);
+ CodeForStatement(node);
Reference target(this, node->target());
if (target.is_illegal()) return;
@@ -2259,7 +2268,7 @@
// Assignment ignored - leave the value on the stack.
} else {
- __ RecordPosition(node->position());
+ CodeForSourcePosition(node->position());
if (node->op() == Token::INIT_CONST) {
// Dynamic constant initializations must use the function context
// and initialize the actual constant declared. Dynamic variable
@@ -2276,7 +2285,7 @@
Comment cmnt(masm_, "[ Throw");
Load(node->exception());
- __ RecordPosition(node->position());
+ CodeForSourcePosition(node->position());
__ CallRuntime(Runtime::kThrow, 1);
frame_->Push(r0);
}
@@ -2295,7 +2304,7 @@
ZoneList<Expression*>* args = node->arguments();
- RecordStatementPosition(node);
+ CodeForStatement(node);
// Standard function call.
// Check if the function is a variable or a property.
@@ -2331,7 +2340,7 @@
// Setup the receiver register and call the IC initialization code.
Handle<Code> stub = ComputeCallInitialize(args->length());
- __ RecordPosition(node->position());
+ CodeForSourcePosition(node->position());
__ Call(stub, RelocInfo::CODE_TARGET_CONTEXT);
__ ldr(cp, frame_->Context());
// Remove the function from the stack.
@@ -2378,7 +2387,7 @@
// Set the receiver register and call the IC initialization code.
Handle<Code> stub = ComputeCallInitialize(args->length());
- __ RecordPosition(node->position());
+ CodeForSourcePosition(node->position());
__ Call(stub, RelocInfo::CODE_TARGET);
__ ldr(cp, frame_->Context());
@@ -2432,7 +2441,7 @@
ZoneList<Expression*>* args = node->arguments();
Expression* function = node->expression();
- RecordStatementPosition(node);
+ CodeForStatement(node);
// Prepare stack for call to resolved function.
Load(function);
@@ -2462,7 +2471,7 @@
__ str(r1, MemOperand(sp, args->length() * kPointerSize));
// Call the function.
- __ RecordPosition(node->position());
+ CodeForSourcePosition(node->position());
CallFunctionStub call_function(args->length());
__ CallStub(&call_function);
@@ -2476,6 +2485,7 @@
void CodeGenerator::VisitCallNew(CallNew* node) {
Comment cmnt(masm_, "[ CallNew");
+ CodeForStatement(node);
// According to ECMA-262, section 11.2.2, page 44, the function
// expression in new calls must be evaluated before the
@@ -2501,7 +2511,7 @@
// Call the construct call builtin that handles allocation and
// constructor invocation.
- __ RecordPosition(RelocInfo::POSITION);
+ CodeForSourcePosition(node->position());
__ Call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)),
RelocInfo::CONSTRUCT_CALL);
@@ -2567,6 +2577,19 @@
}
+void CodeGenerator::GenerateLog(ZoneList<Expression*>* args) {
+ // See comment in CodeGenerator::GenerateLog in codegen-ia32.cc.
+ ASSERT_EQ(args->length(), 3);
+ if (ShouldGenerateLog(args->at(0))) {
+ Load(args->at(1));
+ Load(args->at(2));
+ __ CallRuntime(Runtime::kLog, 2);
+ }
+ __ mov(r0, Operand(Factory::undefined_value()));
+ frame_->Push(r0);
+}
+
+
void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
Load(args->at(0));
@@ -3207,15 +3230,6 @@
}
-void CodeGenerator::RecordStatementPosition(Node* node) {
- if (FLAG_debug_info) {
- int statement_pos = node->statement_pos();
- if (statement_pos == RelocInfo::kNoPosition) return;
- __ RecordStatementPosition(statement_pos);
- }
-}
-
-
#undef __
#define __ masm->
@@ -3243,7 +3257,7 @@
VirtualFrame* frame = cgen_->frame();
Property* property = expression_->AsProperty();
if (property != NULL) {
- __ RecordPosition(property->position());
+ cgen_->CodeForSourcePosition(property->position());
}
switch (type_) {
@@ -3281,6 +3295,9 @@
case KEYED: {
// TODO(1241834): Make sure that this it is safe to ignore the
// distinction between expressions in a typeof and not in a typeof.
+
+ // TODO(181): Implement inlined version of array indexing once
+ // loop nesting is properly tracked on ARM.
Comment cmnt(masm, "[ Load from keyed Property");
ASSERT(property != NULL);
Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
@@ -3309,7 +3326,7 @@
VirtualFrame* frame = cgen_->frame();
Property* property = expression_->AsProperty();
if (property != NULL) {
- __ RecordPosition(property->position());
+ cgen_->CodeForSourcePosition(property->position());
}
switch (type_) {
@@ -3412,7 +3429,7 @@
Comment cmnt(masm, "[ Store to keyed Property");
Property* property = expression_->AsProperty();
ASSERT(property != NULL);
- __ RecordPosition(property->position());
+ cgen_->CodeForSourcePosition(property->position());
// Call IC code.
Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));