OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // o r1: the JS function object being called (ie, ourselves) | 44 // o r1: the JS function object being called (ie, ourselves) |
45 // o cp: our context | 45 // o cp: our context |
46 // o fp: our caller's frame pointer | 46 // o fp: our caller's frame pointer |
47 // o sp: stack pointer | 47 // o sp: stack pointer |
48 // o lr: return address | 48 // o lr: return address |
49 // | 49 // |
50 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 50 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
51 // frames-arm.h for its layout. | 51 // frames-arm.h for its layout. |
52 void FastCodeGenerator::Generate(FunctionLiteral* fun) { | 52 void FastCodeGenerator::Generate(FunctionLiteral* fun) { |
53 function_ = fun; | 53 function_ = fun; |
| 54 // ARM does NOT call SetFunctionPosition. |
54 | 55 |
55 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); | 56 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); |
56 // Adjust fp to point to caller's fp. | 57 // Adjust fp to point to caller's fp. |
57 __ add(fp, sp, Operand(2 * kPointerSize)); | 58 __ add(fp, sp, Operand(2 * kPointerSize)); |
58 | 59 |
59 { Comment cmnt(masm_, "[ Allocate locals"); | 60 { Comment cmnt(masm_, "[ Allocate locals"); |
60 int locals_count = fun->scope()->num_stack_slots(); | 61 int locals_count = fun->scope()->num_stack_slots(); |
61 if (locals_count > 0) { | 62 if (locals_count > 0) { |
62 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 63 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
63 } | 64 } |
(...skipping 21 matching lines...) Expand all Loading... |
85 } | 86 } |
86 | 87 |
87 { Comment cmnt(masm_, "[ Body"); | 88 { Comment cmnt(masm_, "[ Body"); |
88 VisitStatements(fun->body()); | 89 VisitStatements(fun->body()); |
89 } | 90 } |
90 | 91 |
91 { Comment cmnt(masm_, "[ return <undefined>;"); | 92 { Comment cmnt(masm_, "[ return <undefined>;"); |
92 // Emit a 'return undefined' in case control fell off the end of the | 93 // Emit a 'return undefined' in case control fell off the end of the |
93 // body. | 94 // body. |
94 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 95 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 96 SetReturnPosition(fun); |
95 __ RecordJSReturn(); | 97 __ RecordJSReturn(); |
96 __ mov(sp, fp); | 98 __ mov(sp, fp); |
97 __ ldm(ia_w, sp, fp.bit() | lr.bit()); | 99 __ ldm(ia_w, sp, fp.bit() | lr.bit()); |
98 int num_parameters = function_->scope()->num_parameters(); | 100 int num_parameters = function_->scope()->num_parameters(); |
99 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize)); | 101 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize)); |
100 __ Jump(lr); | 102 __ Jump(lr); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
104 | 106 |
105 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { | 107 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { |
106 Comment cmnt(masm_, "[ ExpressionStatement"); | 108 Comment cmnt(masm_, "[ ExpressionStatement"); |
| 109 SetStatementPosition(stmt); |
107 Visit(stmt->expression()); | 110 Visit(stmt->expression()); |
108 __ pop(); | 111 __ pop(); |
109 } | 112 } |
110 | 113 |
111 | 114 |
112 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 115 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { |
113 Comment cmnt(masm_, "[ ReturnStatement"); | 116 Comment cmnt(masm_, "[ ReturnStatement"); |
| 117 SetStatementPosition(stmt); |
114 Visit(stmt->expression()); | 118 Visit(stmt->expression()); |
115 __ pop(r0); | 119 __ pop(r0); |
116 __ RecordJSReturn(); | 120 __ RecordJSReturn(); |
117 __ mov(sp, fp); | 121 __ mov(sp, fp); |
118 __ ldm(ia_w, sp, fp.bit() | lr.bit()); | 122 __ ldm(ia_w, sp, fp.bit() | lr.bit()); |
119 int num_parameters = function_->scope()->num_parameters(); | 123 int num_parameters = function_->scope()->num_parameters(); |
120 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize)); | 124 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize)); |
121 __ Jump(lr); | 125 __ Jump(lr); |
122 } | 126 } |
123 | 127 |
(...skipping 19 matching lines...) Expand all Loading... |
143 Visit(expr->value()); | 147 Visit(expr->value()); |
144 | 148 |
145 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); | 149 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); |
146 ASSERT(var != NULL && var->slot() != NULL); | 150 ASSERT(var != NULL && var->slot() != NULL); |
147 __ ldr(ip, MemOperand(sp)); | 151 __ ldr(ip, MemOperand(sp)); |
148 __ str(ip, MemOperand(fp, SlotOffset(var->slot()))); | 152 __ str(ip, MemOperand(fp, SlotOffset(var->slot()))); |
149 } | 153 } |
150 | 154 |
151 | 155 |
152 } } // namespace v8::internal | 156 } } // namespace v8::internal |
OLD | NEW |