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

Side by Side Diff: src/mips/lithium-codegen-mips.cc

Issue 22255005: MIPS: Replace LoadNamedFieldPolymorphic with explicit branches. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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
« no previous file with comments | « src/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2903 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 Register result = ToRegister(instr->result()); 2914 Register result = ToRegister(instr->result());
2915 if (access.IsInobject()) { 2915 if (access.IsInobject()) {
2916 __ lw(result, FieldMemOperand(object, offset)); 2916 __ lw(result, FieldMemOperand(object, offset));
2917 } else { 2917 } else {
2918 __ lw(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 2918 __ lw(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
2919 __ lw(result, FieldMemOperand(result, offset)); 2919 __ lw(result, FieldMemOperand(result, offset));
2920 } 2920 }
2921 } 2921 }
2922 2922
2923 2923
2924 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result,
2925 Register object,
2926 Handle<Map> type,
2927 Handle<String> name,
2928 LEnvironment* env) {
2929 LookupResult lookup(isolate());
2930 type->LookupDescriptor(NULL, *name, &lookup);
2931 ASSERT(lookup.IsFound() || lookup.IsCacheable());
2932 if (lookup.IsField()) {
2933 int index = lookup.GetLocalFieldIndexFromMap(*type);
2934 int offset = index * kPointerSize;
2935 if (index < 0) {
2936 // Negative property indices are in-object properties, indexed
2937 // from the end of the fixed part of the object.
2938 __ lw(result, FieldMemOperand(object, offset + type->instance_size()));
2939 } else {
2940 // Non-negative property indices are in the properties array.
2941 __ lw(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
2942 __ lw(result, FieldMemOperand(result, offset + FixedArray::kHeaderSize));
2943 }
2944 } else if (lookup.IsConstant()) {
2945 Handle<Object> constant(lookup.GetConstantFromMap(*type), isolate());
2946 __ LoadObject(result, constant);
2947 } else {
2948 // Negative lookup.
2949 // Check prototypes.
2950 Handle<HeapObject> current(HeapObject::cast((*type)->prototype()));
2951 Heap* heap = type->GetHeap();
2952 while (*current != heap->null_value()) {
2953 __ LoadHeapObject(result, current);
2954 __ lw(result, FieldMemOperand(result, HeapObject::kMapOffset));
2955 DeoptimizeIf(ne, env, result, Operand(Handle<Map>(current->map())));
2956 current =
2957 Handle<HeapObject>(HeapObject::cast(current->map()->prototype()));
2958 }
2959 __ LoadRoot(result, Heap::kUndefinedValueRootIndex);
2960 }
2961 }
2962
2963
2964 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2965 Register object = ToRegister(instr->object());
2966 Register result = ToRegister(instr->result());
2967 Register object_map = scratch0();
2968
2969 int map_count = instr->hydrogen()->types()->length();
2970 bool need_generic = instr->hydrogen()->need_generic();
2971
2972 if (map_count == 0 && !need_generic) {
2973 DeoptimizeIf(al, instr->environment());
2974 return;
2975 }
2976 Handle<String> name = instr->hydrogen()->name();
2977 Label done;
2978 __ lw(object_map, FieldMemOperand(object, HeapObject::kMapOffset));
2979 for (int i = 0; i < map_count; ++i) {
2980 bool last = (i == map_count - 1);
2981 Handle<Map> map = instr->hydrogen()->types()->at(i);
2982 Label check_passed;
2983 __ CompareMapAndBranch(object_map, map, &check_passed, eq, &check_passed);
2984 if (last && !need_generic) {
2985 DeoptimizeIf(al, instr->environment());
2986 __ bind(&check_passed);
2987 EmitLoadFieldOrConstantFunction(
2988 result, object, map, name, instr->environment());
2989 } else {
2990 Label next;
2991 __ Branch(&next);
2992 __ bind(&check_passed);
2993 EmitLoadFieldOrConstantFunction(
2994 result, object, map, name, instr->environment());
2995 __ Branch(&done);
2996 __ bind(&next);
2997 }
2998 }
2999 if (need_generic) {
3000 __ li(a2, Operand(name));
3001 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
3002 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3003 }
3004 __ bind(&done);
3005 }
3006
3007
3008 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 2924 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
3009 ASSERT(ToRegister(instr->object()).is(a0)); 2925 ASSERT(ToRegister(instr->object()).is(a0));
3010 ASSERT(ToRegister(instr->result()).is(v0)); 2926 ASSERT(ToRegister(instr->result()).is(v0));
3011 2927
3012 // Name is always in a2. 2928 // Name is always in a2.
3013 __ li(a2, Operand(instr->name())); 2929 __ li(a2, Operand(instr->name()));
3014 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2930 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
3015 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2931 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3016 } 2932 }
3017 2933
(...skipping 2863 matching lines...) Expand 10 before | Expand all | Expand 10 after
5881 __ Subu(scratch, result, scratch); 5797 __ Subu(scratch, result, scratch);
5882 __ lw(result, FieldMemOperand(scratch, 5798 __ lw(result, FieldMemOperand(scratch,
5883 FixedArray::kHeaderSize - kPointerSize)); 5799 FixedArray::kHeaderSize - kPointerSize));
5884 __ bind(&done); 5800 __ bind(&done);
5885 } 5801 }
5886 5802
5887 5803
5888 #undef __ 5804 #undef __
5889 5805
5890 } } // namespace v8::internal 5806 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698