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

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

Issue 22213002: 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/arm/lithium-codegen-arm.h ('k') | src/hydrogen.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 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 3003 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 Register result = ToRegister(instr->result()); 3014 Register result = ToRegister(instr->result());
3015 if (access.IsInobject()) { 3015 if (access.IsInobject()) {
3016 __ ldr(result, FieldMemOperand(object, offset)); 3016 __ ldr(result, FieldMemOperand(object, offset));
3017 } else { 3017 } else {
3018 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 3018 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
3019 __ ldr(result, FieldMemOperand(result, offset)); 3019 __ ldr(result, FieldMemOperand(result, offset));
3020 } 3020 }
3021 } 3021 }
3022 3022
3023 3023
3024 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result,
3025 Register object,
3026 Handle<Map> type,
3027 Handle<String> name,
3028 LEnvironment* env) {
3029 LookupResult lookup(isolate());
3030 type->LookupDescriptor(NULL, *name, &lookup);
3031 ASSERT(lookup.IsFound() || lookup.IsCacheable());
3032 if (lookup.IsField()) {
3033 int index = lookup.GetLocalFieldIndexFromMap(*type);
3034 int offset = index * kPointerSize;
3035 if (index < 0) {
3036 // Negative property indices are in-object properties, indexed
3037 // from the end of the fixed part of the object.
3038 __ ldr(result, FieldMemOperand(object, offset + type->instance_size()));
3039 } else {
3040 // Non-negative property indices are in the properties array.
3041 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
3042 __ ldr(result, FieldMemOperand(result, offset + FixedArray::kHeaderSize));
3043 }
3044 } else if (lookup.IsConstant()) {
3045 Handle<Object> constant(lookup.GetConstantFromMap(*type), isolate());
3046 __ LoadObject(result, constant);
3047 } else {
3048 // Negative lookup.
3049 // Check prototypes.
3050 Handle<HeapObject> current(HeapObject::cast((*type)->prototype()));
3051 Heap* heap = type->GetHeap();
3052 while (*current != heap->null_value()) {
3053 __ LoadHeapObject(result, current);
3054 __ ldr(result, FieldMemOperand(result, HeapObject::kMapOffset));
3055 __ cmp(result, Operand(Handle<Map>(current->map())));
3056 DeoptimizeIf(ne, env);
3057 current =
3058 Handle<HeapObject>(HeapObject::cast(current->map()->prototype()));
3059 }
3060 __ LoadRoot(result, Heap::kUndefinedValueRootIndex);
3061 }
3062 }
3063
3064
3065 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
3066 Register object = ToRegister(instr->object());
3067 Register result = ToRegister(instr->result());
3068 Register object_map = scratch0();
3069
3070 int map_count = instr->hydrogen()->types()->length();
3071 bool need_generic = instr->hydrogen()->need_generic();
3072
3073 if (map_count == 0 && !need_generic) {
3074 DeoptimizeIf(al, instr->environment());
3075 return;
3076 }
3077 Handle<String> name = instr->hydrogen()->name();
3078 Label done;
3079 __ ldr(object_map, FieldMemOperand(object, HeapObject::kMapOffset));
3080 for (int i = 0; i < map_count; ++i) {
3081 bool last = (i == map_count - 1);
3082 Handle<Map> map = instr->hydrogen()->types()->at(i);
3083 Label check_passed;
3084 __ CompareMap(object_map, map, &check_passed);
3085 if (last && !need_generic) {
3086 DeoptimizeIf(ne, instr->environment());
3087 __ bind(&check_passed);
3088 EmitLoadFieldOrConstantFunction(
3089 result, object, map, name, instr->environment());
3090 } else {
3091 Label next;
3092 __ b(ne, &next);
3093 __ bind(&check_passed);
3094 EmitLoadFieldOrConstantFunction(
3095 result, object, map, name, instr->environment());
3096 __ b(&done);
3097 __ bind(&next);
3098 }
3099 }
3100 if (need_generic) {
3101 __ mov(r2, Operand(name));
3102 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
3103 CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
3104 }
3105 __ bind(&done);
3106 }
3107
3108
3109 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 3024 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
3110 ASSERT(ToRegister(instr->object()).is(r0)); 3025 ASSERT(ToRegister(instr->object()).is(r0));
3111 ASSERT(ToRegister(instr->result()).is(r0)); 3026 ASSERT(ToRegister(instr->result()).is(r0));
3112 3027
3113 // Name is always in r2. 3028 // Name is always in r2.
3114 __ mov(r2, Operand(instr->name())); 3029 __ mov(r2, Operand(instr->name()));
3115 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 3030 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
3116 CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); 3031 CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
3117 } 3032 }
3118 3033
(...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after
5839 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); 5754 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index));
5840 __ ldr(result, FieldMemOperand(scratch, 5755 __ ldr(result, FieldMemOperand(scratch,
5841 FixedArray::kHeaderSize - kPointerSize)); 5756 FixedArray::kHeaderSize - kPointerSize));
5842 __ bind(&done); 5757 __ bind(&done);
5843 } 5758 }
5844 5759
5845 5760
5846 #undef __ 5761 #undef __
5847 5762
5848 } } // namespace v8::internal 5763 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698