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

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

Issue 4654002: Move common static helpers from codegen to the macro-assembler files. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 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/arm/codegen-arm.cc ('k') | src/arm/macro-assembler-arm.h » ('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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 __ ldr(temp, ContextOperand(next, Context::EXTENSION_INDEX)); 1012 __ ldr(temp, ContextOperand(next, Context::EXTENSION_INDEX));
1013 __ tst(temp, temp); 1013 __ tst(temp, temp);
1014 __ b(ne, slow); 1014 __ b(ne, slow);
1015 // Load next context in chain. 1015 // Load next context in chain.
1016 __ ldr(next, ContextOperand(next, Context::CLOSURE_INDEX)); 1016 __ ldr(next, ContextOperand(next, Context::CLOSURE_INDEX));
1017 __ ldr(next, FieldMemOperand(next, JSFunction::kContextOffset)); 1017 __ ldr(next, FieldMemOperand(next, JSFunction::kContextOffset));
1018 __ b(&loop); 1018 __ b(&loop);
1019 __ bind(&fast); 1019 __ bind(&fast);
1020 } 1020 }
1021 1021
1022 __ ldr(r0, CodeGenerator::GlobalObject()); 1022 __ ldr(r0, GlobalObjectOperand());
1023 __ mov(r2, Operand(slot->var()->name())); 1023 __ mov(r2, Operand(slot->var()->name()));
1024 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF) 1024 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
1025 ? RelocInfo::CODE_TARGET 1025 ? RelocInfo::CODE_TARGET
1026 : RelocInfo::CODE_TARGET_CONTEXT; 1026 : RelocInfo::CODE_TARGET_CONTEXT;
1027 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 1027 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
1028 EmitCallIC(ic, mode); 1028 EmitCallIC(ic, mode);
1029 } 1029 }
1030 1030
1031 1031
1032 void FullCodeGenerator::EmitVariableLoad(Variable* var) { 1032 void FullCodeGenerator::EmitVariableLoad(Variable* var) {
1033 // Four cases: non-this global variables, lookup slots, all other 1033 // Four cases: non-this global variables, lookup slots, all other
1034 // types of slots, and parameters that rewrite to explicit property 1034 // types of slots, and parameters that rewrite to explicit property
1035 // accesses on the arguments object. 1035 // accesses on the arguments object.
1036 Slot* slot = var->AsSlot(); 1036 Slot* slot = var->AsSlot();
1037 Property* property = var->AsProperty(); 1037 Property* property = var->AsProperty();
1038 1038
1039 if (var->is_global() && !var->is_this()) { 1039 if (var->is_global() && !var->is_this()) {
1040 Comment cmnt(masm_, "Global variable"); 1040 Comment cmnt(masm_, "Global variable");
1041 // Use inline caching. Variable name is passed in r2 and the global 1041 // Use inline caching. Variable name is passed in r2 and the global
1042 // object (receiver) in r0. 1042 // object (receiver) in r0.
1043 __ ldr(r0, CodeGenerator::GlobalObject()); 1043 __ ldr(r0, GlobalObjectOperand());
1044 __ mov(r2, Operand(var->name())); 1044 __ mov(r2, Operand(var->name()));
1045 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 1045 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
1046 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); 1046 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
1047 context()->Plug(r0); 1047 context()->Plug(r0);
1048 1048
1049 } else if (slot != NULL && slot->type() == Slot::LOOKUP) { 1049 } else if (slot != NULL && slot->type() == Slot::LOOKUP) {
1050 Label done, slow; 1050 Label done, slow;
1051 1051
1052 // Generate code for loading from variables potentially shadowed 1052 // Generate code for loading from variables potentially shadowed
1053 // by eval-introduced variables. 1053 // by eval-introduced variables.
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 // here. 1507 // here.
1508 ASSERT(var != NULL); 1508 ASSERT(var != NULL);
1509 ASSERT(var->is_global() || var->AsSlot() != NULL); 1509 ASSERT(var->is_global() || var->AsSlot() != NULL);
1510 1510
1511 if (var->is_global()) { 1511 if (var->is_global()) {
1512 ASSERT(!var->is_this()); 1512 ASSERT(!var->is_this());
1513 // Assignment to a global variable. Use inline caching for the 1513 // Assignment to a global variable. Use inline caching for the
1514 // assignment. Right-hand-side value is passed in r0, variable name in 1514 // assignment. Right-hand-side value is passed in r0, variable name in
1515 // r2, and the global object in r1. 1515 // r2, and the global object in r1.
1516 __ mov(r2, Operand(var->name())); 1516 __ mov(r2, Operand(var->name()));
1517 __ ldr(r1, CodeGenerator::GlobalObject()); 1517 __ ldr(r1, GlobalObjectOperand());
1518 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); 1518 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
1519 EmitCallIC(ic, RelocInfo::CODE_TARGET); 1519 EmitCallIC(ic, RelocInfo::CODE_TARGET);
1520 1520
1521 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) { 1521 } else if (var->mode() != Variable::CONST || op == Token::INIT_CONST) {
1522 // Perform the assignment for non-const variables and for initialization 1522 // Perform the assignment for non-const variables and for initialization
1523 // of const variables. Const assignments are simply skipped. 1523 // of const variables. Const assignments are simply skipped.
1524 Label done; 1524 Label done;
1525 Slot* slot = var->AsSlot(); 1525 Slot* slot = var->AsSlot();
1526 switch (slot->type()) { 1526 switch (slot->type()) {
1527 case Slot::PARAMETER: 1527 case Slot::PARAMETER:
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 // Record source position for debugger. 1802 // Record source position for debugger.
1803 SetSourcePosition(expr->position(), FORCED_POSITION); 1803 SetSourcePosition(expr->position(), FORCED_POSITION);
1804 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP; 1804 InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
1805 CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE); 1805 CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE);
1806 __ CallStub(&stub); 1806 __ CallStub(&stub);
1807 // Restore context register. 1807 // Restore context register.
1808 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 1808 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
1809 context()->DropAndPlug(1, r0); 1809 context()->DropAndPlug(1, r0);
1810 } else if (var != NULL && !var->is_this() && var->is_global()) { 1810 } else if (var != NULL && !var->is_this() && var->is_global()) {
1811 // Push global object as receiver for the call IC. 1811 // Push global object as receiver for the call IC.
1812 __ ldr(r0, CodeGenerator::GlobalObject()); 1812 __ ldr(r0, GlobalObjectOperand());
1813 __ push(r0); 1813 __ push(r0);
1814 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT); 1814 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT);
1815 } else if (var != NULL && var->AsSlot() != NULL && 1815 } else if (var != NULL && var->AsSlot() != NULL &&
1816 var->AsSlot()->type() == Slot::LOOKUP) { 1816 var->AsSlot()->type() == Slot::LOOKUP) {
1817 // Call to a lookup slot (dynamically introduced variable). 1817 // Call to a lookup slot (dynamically introduced variable).
1818 Label slow, done; 1818 Label slow, done;
1819 1819
1820 { PreserveStatementPositionScope scope(masm()->positions_recorder()); 1820 { PreserveStatementPositionScope scope(masm()->positions_recorder());
1821 // Generate code for loading from variables potentially shadowed 1821 // Generate code for loading from variables potentially shadowed
1822 // by eval-introduced variables. 1822 // by eval-introduced variables.
(...skipping 15 matching lines...) Expand all
1838 // If fast case code has been generated, emit code to push the 1838 // If fast case code has been generated, emit code to push the
1839 // function and receiver and have the slow path jump around this 1839 // function and receiver and have the slow path jump around this
1840 // code. 1840 // code.
1841 if (done.is_linked()) { 1841 if (done.is_linked()) {
1842 Label call; 1842 Label call;
1843 __ b(&call); 1843 __ b(&call);
1844 __ bind(&done); 1844 __ bind(&done);
1845 // Push function. 1845 // Push function.
1846 __ push(r0); 1846 __ push(r0);
1847 // Push global receiver. 1847 // Push global receiver.
1848 __ ldr(r1, CodeGenerator::GlobalObject()); 1848 __ ldr(r1, GlobalObjectOperand());
1849 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); 1849 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
1850 __ push(r1); 1850 __ push(r1);
1851 __ bind(&call); 1851 __ bind(&call);
1852 } 1852 }
1853 1853
1854 EmitCallWithStub(expr); 1854 EmitCallWithStub(expr);
1855 } else if (fun->AsProperty() != NULL) { 1855 } else if (fun->AsProperty() != NULL) {
1856 // Call to an object property. 1856 // Call to an object property.
1857 Property* prop = fun->AsProperty(); 1857 Property* prop = fun->AsProperty();
1858 Literal* key = prop->key()->AsLiteral(); 1858 Literal* key = prop->key()->AsLiteral();
(...skipping 13 matching lines...) Expand all
1872 if (prop->is_synthetic()) { 1872 if (prop->is_synthetic()) {
1873 { PreserveStatementPositionScope scope(masm()->positions_recorder()); 1873 { PreserveStatementPositionScope scope(masm()->positions_recorder());
1874 VisitForAccumulatorValue(prop->key()); 1874 VisitForAccumulatorValue(prop->key());
1875 } 1875 }
1876 // Record source code position for IC call. 1876 // Record source code position for IC call.
1877 SetSourcePosition(prop->position(), FORCED_POSITION); 1877 SetSourcePosition(prop->position(), FORCED_POSITION);
1878 __ pop(r1); // We do not need to keep the receiver. 1878 __ pop(r1); // We do not need to keep the receiver.
1879 1879
1880 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); 1880 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
1881 EmitCallIC(ic, RelocInfo::CODE_TARGET); 1881 EmitCallIC(ic, RelocInfo::CODE_TARGET);
1882 __ ldr(r1, CodeGenerator::GlobalObject()); 1882 __ ldr(r1, GlobalObjectOperand());
1883 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); 1883 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
1884 __ Push(r0, r1); // Function, receiver. 1884 __ Push(r0, r1); // Function, receiver.
1885 EmitCallWithStub(expr); 1885 EmitCallWithStub(expr);
1886 } else { 1886 } else {
1887 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET); 1887 EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET);
1888 } 1888 }
1889 } 1889 }
1890 } else { 1890 } else {
1891 // Call to some other expression. If the expression is an anonymous 1891 // Call to some other expression. If the expression is an anonymous
1892 // function literal not called in a loop, mark it as one that should 1892 // function literal not called in a loop, mark it as one that should
1893 // also use the fast code generator. 1893 // also use the fast code generator.
1894 FunctionLiteral* lit = fun->AsFunctionLiteral(); 1894 FunctionLiteral* lit = fun->AsFunctionLiteral();
1895 if (lit != NULL && 1895 if (lit != NULL &&
1896 lit->name()->Equals(Heap::empty_string()) && 1896 lit->name()->Equals(Heap::empty_string()) &&
1897 loop_depth() == 0) { 1897 loop_depth() == 0) {
1898 lit->set_try_full_codegen(true); 1898 lit->set_try_full_codegen(true);
1899 } 1899 }
1900 1900
1901 { PreserveStatementPositionScope scope(masm()->positions_recorder()); 1901 { PreserveStatementPositionScope scope(masm()->positions_recorder());
1902 VisitForStackValue(fun); 1902 VisitForStackValue(fun);
1903 } 1903 }
1904 // Load global receiver object. 1904 // Load global receiver object.
1905 __ ldr(r1, CodeGenerator::GlobalObject()); 1905 __ ldr(r1, GlobalObjectOperand());
1906 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); 1906 __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
1907 __ push(r1); 1907 __ push(r1);
1908 // Emit function call. 1908 // Emit function call.
1909 EmitCallWithStub(expr); 1909 EmitCallWithStub(expr);
1910 } 1910 }
1911 } 1911 }
1912 1912
1913 1913
1914 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 1914 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
1915 Comment cmnt(masm_, "[ CallNew"); 1915 Comment cmnt(masm_, "[ CallNew");
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 Comment cmnt(masm_, "[ InlineRuntimeCall"); 2773 Comment cmnt(masm_, "[ InlineRuntimeCall");
2774 EmitInlineRuntimeCall(expr); 2774 EmitInlineRuntimeCall(expr);
2775 return; 2775 return;
2776 } 2776 }
2777 2777
2778 Comment cmnt(masm_, "[ CallRuntime"); 2778 Comment cmnt(masm_, "[ CallRuntime");
2779 ZoneList<Expression*>* args = expr->arguments(); 2779 ZoneList<Expression*>* args = expr->arguments();
2780 2780
2781 if (expr->is_jsruntime()) { 2781 if (expr->is_jsruntime()) {
2782 // Prepare for calling JS runtime function. 2782 // Prepare for calling JS runtime function.
2783 __ ldr(r0, CodeGenerator::GlobalObject()); 2783 __ ldr(r0, GlobalObjectOperand());
2784 __ ldr(r0, FieldMemOperand(r0, GlobalObject::kBuiltinsOffset)); 2784 __ ldr(r0, FieldMemOperand(r0, GlobalObject::kBuiltinsOffset));
2785 __ push(r0); 2785 __ push(r0);
2786 } 2786 }
2787 2787
2788 // Push the arguments ("left-to-right"). 2788 // Push the arguments ("left-to-right").
2789 int arg_count = args->length(); 2789 int arg_count = args->length();
2790 for (int i = 0; i < arg_count; i++) { 2790 for (int i = 0; i < arg_count; i++) {
2791 VisitForStackValue(args->at(i)); 2791 VisitForStackValue(args->at(i));
2792 } 2792 }
2793 2793
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 // Result of deleting non-global, non-dynamic variables is false. 2825 // Result of deleting non-global, non-dynamic variables is false.
2826 // The subexpression does not have side effects. 2826 // The subexpression does not have side effects.
2827 context()->Plug(false); 2827 context()->Plug(false);
2828 } else { 2828 } else {
2829 // Property or variable reference. Call the delete builtin with 2829 // Property or variable reference. Call the delete builtin with
2830 // object and property name as arguments. 2830 // object and property name as arguments.
2831 if (prop != NULL) { 2831 if (prop != NULL) {
2832 VisitForStackValue(prop->obj()); 2832 VisitForStackValue(prop->obj());
2833 VisitForStackValue(prop->key()); 2833 VisitForStackValue(prop->key());
2834 } else if (var->is_global()) { 2834 } else if (var->is_global()) {
2835 __ ldr(r1, CodeGenerator::GlobalObject()); 2835 __ ldr(r1, GlobalObjectOperand());
2836 __ mov(r0, Operand(var->name())); 2836 __ mov(r0, Operand(var->name()));
2837 __ Push(r1, r0); 2837 __ Push(r1, r0);
2838 } else { 2838 } else {
2839 // Non-global variable. Call the runtime to look up the context 2839 // Non-global variable. Call the runtime to look up the context
2840 // where the variable was introduced. 2840 // where the variable was introduced.
2841 __ push(context_register()); 2841 __ push(context_register());
2842 __ mov(r2, Operand(var->name())); 2842 __ mov(r2, Operand(var->name()));
2843 __ push(r2); 2843 __ push(r2);
2844 __ CallRuntime(Runtime::kLookupContext, 2); 2844 __ CallRuntime(Runtime::kLookupContext, 2);
2845 __ push(r0); 2845 __ push(r0);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3091 } 3091 }
3092 } 3092 }
3093 3093
3094 3094
3095 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { 3095 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
3096 ASSERT(!context()->IsEffect()); 3096 ASSERT(!context()->IsEffect());
3097 ASSERT(!context()->IsTest()); 3097 ASSERT(!context()->IsTest());
3098 VariableProxy* proxy = expr->AsVariableProxy(); 3098 VariableProxy* proxy = expr->AsVariableProxy();
3099 if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) { 3099 if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) {
3100 Comment cmnt(masm_, "Global variable"); 3100 Comment cmnt(masm_, "Global variable");
3101 __ ldr(r0, CodeGenerator::GlobalObject()); 3101 __ ldr(r0, GlobalObjectOperand());
3102 __ mov(r2, Operand(proxy->name())); 3102 __ mov(r2, Operand(proxy->name()));
3103 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 3103 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
3104 // Use a regular load, not a contextual load, to avoid a reference 3104 // Use a regular load, not a contextual load, to avoid a reference
3105 // error. 3105 // error.
3106 EmitCallIC(ic, RelocInfo::CODE_TARGET); 3106 EmitCallIC(ic, RelocInfo::CODE_TARGET);
3107 context()->Plug(r0); 3107 context()->Plug(r0);
3108 } else if (proxy != NULL && 3108 } else if (proxy != NULL &&
3109 proxy->var()->AsSlot() != NULL && 3109 proxy->var()->AsSlot() != NULL &&
3110 proxy->var()->AsSlot()->type() == Slot::LOOKUP) { 3110 proxy->var()->AsSlot()->type() == Slot::LOOKUP) {
3111 Label done, slow; 3111 Label done, slow;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
3422 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. 3422 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
3423 __ add(pc, r1, Operand(masm_->CodeObject())); 3423 __ add(pc, r1, Operand(masm_->CodeObject()));
3424 } 3424 }
3425 3425
3426 3426
3427 #undef __ 3427 #undef __
3428 3428
3429 } } // namespace v8::internal 3429 } } // namespace v8::internal
3430 3430
3431 #endif // V8_TARGET_ARCH_ARM 3431 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.cc ('k') | src/arm/macro-assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698