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

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

Issue 368005: Add support for all declarations in the top-level compiler: ... (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 | « no previous file | src/compiler.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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // translate it into control flow to the pair of labels. 287 // translate it into control flow to the pair of labels.
288 __ push(source); 288 __ push(source);
289 __ CallRuntime(Runtime::kToBool, 1); 289 __ CallRuntime(Runtime::kToBool, 1);
290 __ LoadRoot(ip, Heap::kTrueValueRootIndex); 290 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
291 __ cmp(r0, ip); 291 __ cmp(r0, ip);
292 __ b(eq, true_label); 292 __ b(eq, true_label);
293 __ jmp(false_label); 293 __ jmp(false_label);
294 } 294 }
295 295
296 296
297 void FastCodeGenerator::VisitDeclaration(Declaration* decl) {
298 Variable* var = decl->proxy()->var();
299 ASSERT(var != NULL); // Must have been resolved.
300 Slot* slot = var->slot();
301 ASSERT(slot != NULL); // No global declarations here.
302
303 // We have 3 cases for slots: LOOKUP, LOCAL, CONTEXT.
304 switch (slot->type()) {
305 case Slot::LOOKUP: {
306 __ mov(r2, Operand(var->name()));
307 // Declaration nodes are always introduced in one of two modes.
308 ASSERT(decl->mode() == Variable::VAR || decl->mode() == Variable::CONST);
309 PropertyAttributes attr = decl->mode() == Variable::VAR ?
310 NONE : READ_ONLY;
311 __ mov(r1, Operand(Smi::FromInt(attr)));
312 // Push initial value, if any.
313 // Note: For variables we must not push an initial value (such as
314 // 'undefined') because we may have a (legal) redeclaration and we
315 // must not destroy the current value.
316 if (decl->mode() == Variable::CONST) {
317 __ mov(r0, Operand(Factory::the_hole_value()));
318 __ stm(db_w, sp, cp.bit() | r2.bit() | r1.bit() | r0.bit());
319 } else if (decl->fun() != NULL) {
320 __ stm(db_w, sp, cp.bit() | r2.bit() | r1.bit());
321 Visit(decl->fun()); // Initial value for function decl.
322 } else {
323 __ mov(r0, Operand(Smi::FromInt(0))); // No initial value!
324 __ stm(db_w, sp, cp.bit() | r2.bit() | r1.bit() | r0.bit());
325 }
326 __ CallRuntime(Runtime::kDeclareContextSlot, 4);
327 break;
328 }
329 case Slot::LOCAL:
330 if (decl->mode() == Variable::CONST) {
331 __ mov(r0, Operand(Factory::the_hole_value()));
332 __ str(r0, MemOperand(fp, SlotOffset(var->slot())));
333 } else if (decl->fun() != NULL) {
334 Visit(decl->fun());
335 __ pop(r0);
336 __ str(r0, MemOperand(fp, SlotOffset(var->slot())));
337 }
338 break;
339 case Slot::CONTEXT:
340 // The variable in the decl always resides in the current context.
341 ASSERT(function_->scope()->ContextChainLength(slot->var()->scope()) == 0);
342 if (decl->mode() == Variable::CONST) {
343 __ mov(r0, Operand(Factory::the_hole_value()));
344 if (FLAG_debug_code) {
345 // Check if we have the correct context pointer.
346 __ ldr(r1, CodeGenerator::ContextOperand(
347 cp, Context::FCONTEXT_INDEX));
348 __ cmp(r1, cp);
349 __ Check(eq, "Unexpected declaration in current context.");
350 }
351 __ str(r0, CodeGenerator::ContextOperand(cp, slot->index()));
352 // No write barrier since the_hole_value is in old space.
353 ASSERT(Heap::InNewSpace(*Factory::the_hole_value()));
354 } else if (decl->fun() != NULL) {
355 Visit(decl->fun());
356 __ pop(r0);
357 if (FLAG_debug_code) {
358 // Check if we have the correct context pointer.
359 __ ldr(r1, CodeGenerator::ContextOperand(
360 cp, Context::FCONTEXT_INDEX));
361 __ cmp(r1, cp);
362 __ Check(eq, "Unexpected declaration in current context.");
363 }
364 __ str(r0, CodeGenerator::ContextOperand(cp, slot->index()));
365 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize;
366 __ mov(r2, Operand(offset));
367 __ RecordWrite(cp, r2, r0);
368 }
369 break;
370 default:
371 UNREACHABLE();
372 }
373 }
374
375
297 void FastCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { 376 void FastCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
298 // Call the runtime to declare the globals. 377 // Call the runtime to declare the globals.
299 // The context is the first argument. 378 // The context is the first argument.
300 __ mov(r1, Operand(pairs)); 379 __ mov(r1, Operand(pairs));
301 __ mov(r0, Operand(Smi::FromInt(is_eval_ ? 1 : 0))); 380 __ mov(r0, Operand(Smi::FromInt(is_eval_ ? 1 : 0)));
302 __ stm(db_w, sp, cp.bit() | r1.bit() | r0.bit()); 381 __ stm(db_w, sp, cp.bit() | r1.bit() | r0.bit());
303 __ CallRuntime(Runtime::kDeclareGlobals, 3); 382 __ CallRuntime(Runtime::kDeclareGlobals, 3);
304 // Return value is ignored. 383 // Return value is ignored.
305 } 384 }
306 385
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 true_label_ = saved_true; 1426 true_label_ = saved_true;
1348 false_label_ = saved_false; 1427 false_label_ = saved_false;
1349 // Convert current context to test context: End post-test code. 1428 // Convert current context to test context: End post-test code.
1350 } 1429 }
1351 1430
1352 1431
1353 #undef __ 1432 #undef __
1354 1433
1355 1434
1356 } } // namespace v8::internal 1435 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698