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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 6384020: Remove the redundant load on every context lookup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build/ia32
Patch Set: Created 9 years, 10 months 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { 1516 void MacroAssembler::LoadContext(Register dst, int context_chain_length) {
1517 if (context_chain_length > 0) { 1517 if (context_chain_length > 0) {
1518 // Move up the chain of contexts to the context containing the slot. 1518 // Move up the chain of contexts to the context containing the slot.
1519 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); 1519 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX)));
1520 // Load the function context (which is the incoming, outer context). 1520 // Load the function context (which is the incoming, outer context).
1521 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); 1521 mov(dst, FieldOperand(dst, JSFunction::kContextOffset));
1522 for (int i = 1; i < context_chain_length; i++) { 1522 for (int i = 1; i < context_chain_length; i++) {
1523 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); 1523 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX)));
1524 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); 1524 mov(dst, FieldOperand(dst, JSFunction::kContextOffset));
1525 } 1525 }
1526 // The context may be an intermediate context, not a function context. 1526 } else {
1527 mov(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); 1527 // Slot is in the current function context. Move it into the
1528 } else { // Slot is in the current function context. 1528 // destination register in case we store into it (the write barrier
1529 // The context may be an intermediate context, not a function context. 1529 // cannot be allowed to destroy the context in esi).
1530 mov(dst, Operand(esi, Context::SlotOffset(Context::FCONTEXT_INDEX))); 1530 mov(dst, esi);
1531 } 1531 }
1532
1533 // We should not have found a 'with' context by walking the context chain
1534 // (i.e., the static scope chain and runtime context chain do not agree).
1535 // A variable occurring in such a scope should have slot type LOOKUP and
1536 // not CONTEXT.
1537 cmp(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX)));
fschneider 2011/02/04 11:29:58 Shouldn't this be inside if (FLAG_debug_code)?
Kevin Millikin (Chromium) 2011/02/04 11:51:48 Good catch.
1538 Check(equal, "Yo dawg, I heard you liked function contexts "
1539 "so I put function contexts in all your contexts");
1532 } 1540 }
1533 1541
1534 1542
1535 void MacroAssembler::LoadGlobalFunction(int index, Register function) { 1543 void MacroAssembler::LoadGlobalFunction(int index, Register function) {
1536 // Load the global or builtins object from the current context. 1544 // Load the global or builtins object from the current context.
1537 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); 1545 mov(function, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
1538 // Load the global context from the global or builtins object. 1546 // Load the global context from the global or builtins object.
1539 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset)); 1547 mov(function, FieldOperand(function, GlobalObject::kGlobalContextOffset));
1540 // Load the function from the global context. 1548 // Load the function from the global context.
1541 mov(function, Operand(function, Context::SlotOffset(index))); 1549 mov(function, Operand(function, Context::SlotOffset(index)));
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 1897
1890 // Check that the code was patched as expected. 1898 // Check that the code was patched as expected.
1891 ASSERT(masm_.pc_ == address_ + size_); 1899 ASSERT(masm_.pc_ == address_ + size_);
1892 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 1900 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
1893 } 1901 }
1894 1902
1895 1903
1896 } } // namespace v8::internal 1904 } } // namespace v8::internal
1897 1905
1898 #endif // V8_TARGET_ARCH_IA32 1906 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/ia32/lithium-ia32.cc ('K') | « src/ia32/lithium-ia32.cc ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698