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

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

Issue 6930005: Support polymorphic loads of constant functions as well as fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Implement arm and x64 part Created 9 years, 7 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-instructions.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 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 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 Register result = ToRegister(instr->result()); 2277 Register result = ToRegister(instr->result());
2278 if (instr->hydrogen()->is_in_object()) { 2278 if (instr->hydrogen()->is_in_object()) {
2279 __ ldr(result, FieldMemOperand(object, instr->hydrogen()->offset())); 2279 __ ldr(result, FieldMemOperand(object, instr->hydrogen()->offset()));
2280 } else { 2280 } else {
2281 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 2281 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
2282 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset())); 2282 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset()));
2283 } 2283 }
2284 } 2284 }
2285 2285
2286 2286
2287 void LCodeGen::EmitLoadField(Register result, 2287 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result,
2288 Register object, 2288 Register object,
2289 Handle<Map> type, 2289 Handle<Map> type,
2290 Handle<String> name) { 2290 Handle<String> name) {
2291 LookupResult lookup; 2291 LookupResult lookup;
2292 type->LookupInDescriptors(NULL, *name, &lookup); 2292 type->LookupInDescriptors(NULL, *name, &lookup);
2293 ASSERT(lookup.IsProperty() && lookup.type() == FIELD); 2293 ASSERT(lookup.IsProperty() &&
2294 int index = lookup.GetLocalFieldIndexFromMap(*type); 2294 (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION));
2295 int offset = index * kPointerSize; 2295 if (lookup.type() == FIELD) {
2296 if (index < 0) { 2296 int index = lookup.GetLocalFieldIndexFromMap(*type);
2297 // Negative property indices are in-object properties, indexed 2297 int offset = index * kPointerSize;
2298 // from the end of the fixed part of the object. 2298 if (index < 0) {
2299 __ ldr(result, FieldMemOperand(object, offset + type->instance_size())); 2299 // Negative property indices are in-object properties, indexed
2300 // from the end of the fixed part of the object.
2301 __ ldr(result, FieldMemOperand(object, offset + type->instance_size()));
2302 } else {
2303 // Non-negative property indices are in the properties array.
2304 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
2305 __ ldr(result, FieldMemOperand(result, offset + FixedArray::kHeaderSize));
2306 }
2300 } else { 2307 } else {
2301 // Non-negative property indices are in the properties array. 2308 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type));
2302 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 2309 LoadHeapObject(result, Handle<HeapObject>::cast(function));
2303 __ ldr(result, FieldMemOperand(result, offset + FixedArray::kHeaderSize));
2304 } 2310 }
2305 } 2311 }
2306 2312
2307 2313
2308 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { 2314 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2309 Register object = ToRegister(instr->object()); 2315 Register object = ToRegister(instr->object());
2310 Register result = ToRegister(instr->result()); 2316 Register result = ToRegister(instr->result());
2311 Register scratch = scratch0(); 2317 Register scratch = scratch0();
2312 int map_count = instr->hydrogen()->types()->length(); 2318 int map_count = instr->hydrogen()->types()->length();
2313 Handle<String> name = instr->hydrogen()->name(); 2319 Handle<String> name = instr->hydrogen()->name();
2314 if (map_count == 0) { 2320 if (map_count == 0) {
2315 ASSERT(instr->hydrogen()->need_generic()); 2321 ASSERT(instr->hydrogen()->need_generic());
2316 __ mov(r2, Operand(name)); 2322 __ mov(r2, Operand(name));
2317 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2323 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2318 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2324 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2319 } else { 2325 } else {
2320 Label done; 2326 Label done;
2321 __ ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); 2327 __ ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
2322 for (int i = 0; i < map_count - 1; ++i) { 2328 for (int i = 0; i < map_count - 1; ++i) {
2323 Handle<Map> map = instr->hydrogen()->types()->at(i); 2329 Handle<Map> map = instr->hydrogen()->types()->at(i);
2324 Label next; 2330 Label next;
2325 __ cmp(scratch, Operand(map)); 2331 __ cmp(scratch, Operand(map));
2326 __ b(ne, &next); 2332 __ b(ne, &next);
2327 EmitLoadField(result, object, map, name); 2333 EmitLoadFieldOrConstantFunction(result, object, map, name);
2328 __ b(&done); 2334 __ b(&done);
2329 __ bind(&next); 2335 __ bind(&next);
2330 } 2336 }
2331 Handle<Map> map = instr->hydrogen()->types()->last(); 2337 Handle<Map> map = instr->hydrogen()->types()->last();
2332 __ cmp(scratch, Operand(map)); 2338 __ cmp(scratch, Operand(map));
2333 if (instr->hydrogen()->need_generic()) { 2339 if (instr->hydrogen()->need_generic()) {
2334 Label generic; 2340 Label generic;
2335 __ b(ne, &generic); 2341 __ b(ne, &generic);
2336 EmitLoadField(result, object, map, name); 2342 EmitLoadFieldOrConstantFunction(result, object, map, name);
2337 __ b(&done); 2343 __ b(&done);
2338 __ bind(&generic); 2344 __ bind(&generic);
2339 __ mov(r2, Operand(name)); 2345 __ mov(r2, Operand(name));
2340 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2346 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2341 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2347 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2342 } else { 2348 } else {
2343 DeoptimizeIf(ne, instr->environment()); 2349 DeoptimizeIf(ne, instr->environment());
2344 EmitLoadField(result, object, map, name); 2350 EmitLoadFieldOrConstantFunction(result, object, map, name);
2345 } 2351 }
2346 __ bind(&done); 2352 __ bind(&done);
2347 } 2353 }
2348 } 2354 }
2349 2355
2350 2356
2351 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 2357 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2352 ASSERT(ToRegister(instr->object()).is(r0)); 2358 ASSERT(ToRegister(instr->object()).is(r0));
2353 ASSERT(ToRegister(instr->result()).is(r0)); 2359 ASSERT(ToRegister(instr->result()).is(r0));
2354 2360
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after
4303 ASSERT(osr_pc_offset_ == -1); 4309 ASSERT(osr_pc_offset_ == -1);
4304 osr_pc_offset_ = masm()->pc_offset(); 4310 osr_pc_offset_ = masm()->pc_offset();
4305 } 4311 }
4306 4312
4307 4313
4308 4314
4309 4315
4310 #undef __ 4316 #undef __
4311 4317
4312 } } // namespace v8::internal 4318 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698