Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: src/fast-codegen.cc

Issue 338043: Make it more pleasant to work with expression locations in the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/fast-codegen.h ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 if (cgen.HasStackOverflow()) { 46 if (cgen.HasStackOverflow()) {
47 ASSERT(!Top::has_pending_exception()); 47 ASSERT(!Top::has_pending_exception());
48 return Handle<Code>::null(); 48 return Handle<Code>::null();
49 } 49 }
50 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP); 50 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP);
51 return CodeGenerator::MakeCodeEpilogue(fun, &masm, flags, script); 51 return CodeGenerator::MakeCodeEpilogue(fun, &masm, flags, script);
52 } 52 }
53 53
54 54
55 int FastCodeGenerator::SlotOffset(Slot* slot) { 55 int FastCodeGenerator::SlotOffset(Slot* slot) {
56 ASSERT(slot != NULL);
56 // Offset is negative because higher indexes are at lower addresses. 57 // Offset is negative because higher indexes are at lower addresses.
57 int offset = -slot->index() * kPointerSize; 58 int offset = -slot->index() * kPointerSize;
58 // Adjust by a (parameter or local) base offset. 59 // Adjust by a (parameter or local) base offset.
59 switch (slot->type()) { 60 switch (slot->type()) {
60 case Slot::PARAMETER: 61 case Slot::PARAMETER:
61 offset += (function_->scope()->num_parameters() + 1) * kPointerSize; 62 offset += (function_->scope()->num_parameters() + 1) * kPointerSize;
62 break; 63 break;
63 case Slot::LOCAL: 64 case Slot::LOCAL:
64 offset += JavaScriptFrameConstants::kLocal0Offset; 65 offset += JavaScriptFrameConstants::kLocal0Offset;
65 break; 66 break;
66 default: 67 default:
67 UNREACHABLE(); 68 UNREACHABLE();
68 } 69 }
69 return offset; 70 return offset;
70 } 71 }
71 72
72 73
74 void FastCodeGenerator::Move(Location destination, Location source) {
75 switch (destination.type()) {
76 case Location::NOWHERE:
77 break;
78
79 case Location::TEMP:
80 switch (source.type()) {
81 case Location::NOWHERE:
82 UNREACHABLE();
83 case Location::TEMP:
84 break;
85 }
86 break;
87 }
88 }
89
90
91 // All platform macro assemblers in {ia32,x64,arm} have a push(Register)
92 // function.
93 void FastCodeGenerator::Move(Location destination, Register source) {
94 switch (destination.type()) {
95 case Location::NOWHERE:
96 break;
97 case Location::TEMP:
98 masm_->push(source);
99 break;
100 }
101 }
102
103
104 // All platform macro assemblers in {ia32,x64,arm} have a pop(Register)
105 // function.
106 void FastCodeGenerator::Move(Register destination, Location source) {
107 switch (source.type()) {
108 case Location::NOWHERE:
109 UNREACHABLE();
110 case Location::TEMP:
111 masm_->pop(destination);
112 }
113 }
114
115
73 void FastCodeGenerator::VisitDeclarations( 116 void FastCodeGenerator::VisitDeclarations(
74 ZoneList<Declaration*>* declarations) { 117 ZoneList<Declaration*>* declarations) {
75 int length = declarations->length(); 118 int length = declarations->length();
76 int globals = 0; 119 int globals = 0;
77 for (int i = 0; i < length; i++) { 120 for (int i = 0; i < length; i++) {
78 Declaration* node = declarations->at(i); 121 Declaration* node = declarations->at(i);
79 Variable* var = node->proxy()->var(); 122 Variable* var = node->proxy()->var();
80 Slot* slot = var->slot(); 123 Slot* slot = var->slot();
81 124
82 // If it was not possible to allocate the variable at compile 125 // If it was not possible to allocate the variable at compile
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 masm_->RecordPosition(pos); 227 masm_->RecordPosition(pos);
185 } 228 }
186 } 229 }
187 230
188 231
189 void FastCodeGenerator::VisitDeclaration(Declaration* decl) { 232 void FastCodeGenerator::VisitDeclaration(Declaration* decl) {
190 UNREACHABLE(); 233 UNREACHABLE();
191 } 234 }
192 235
193 236
237 void FastCodeGenerator::VisitBlock(Block* stmt) {
238 Comment cmnt(masm_, "[ Block");
239 SetStatementPosition(stmt);
240 VisitStatements(stmt->statements());
241 }
242
243
244 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) {
245 Comment cmnt(masm_, "[ ExpressionStatement");
246 SetStatementPosition(stmt);
247 Visit(stmt->expression());
248 }
249
250
194 void FastCodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) { 251 void FastCodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) {
195 Comment cmnt(masm_, "[ EmptyStatement"); 252 Comment cmnt(masm_, "[ EmptyStatement");
196 SetStatementPosition(stmt); 253 SetStatementPosition(stmt);
197 } 254 }
198 255
199 256
200 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) { 257 void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) {
201 UNREACHABLE(); 258 UNREACHABLE();
202 } 259 }
203 260
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 UNREACHABLE(); 329 UNREACHABLE();
273 } 330 }
274 331
275 332
276 void FastCodeGenerator::VisitSlot(Slot* expr) { 333 void FastCodeGenerator::VisitSlot(Slot* expr) {
277 // Slots do not appear directly in the AST. 334 // Slots do not appear directly in the AST.
278 UNREACHABLE(); 335 UNREACHABLE();
279 } 336 }
280 337
281 338
339 void FastCodeGenerator::VisitLiteral(Literal* expr) {
340 Move(expr->location(), expr);
341 }
342
343
282 void FastCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) { 344 void FastCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) {
283 UNREACHABLE(); 345 UNREACHABLE();
284 } 346 }
285 347
286 348
287 void FastCodeGenerator::VisitThrow(Throw* expr) { 349 void FastCodeGenerator::VisitThrow(Throw* expr) {
288 UNREACHABLE(); 350 UNREACHABLE();
289 } 351 }
290 352
291 353
(...skipping 21 matching lines...) Expand all
313 UNREACHABLE(); 375 UNREACHABLE();
314 } 376 }
315 377
316 378
317 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { 379 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
318 UNREACHABLE(); 380 UNREACHABLE();
319 } 381 }
320 382
321 383
322 } } // namespace v8::internal 384 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/fast-codegen.h ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698