| OLD | NEW |
| 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 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 __ PushHeapObject(Handle<HeapObject>::cast(object)); | 2350 __ PushHeapObject(Handle<HeapObject>::cast(object)); |
| 2351 } | 2351 } |
| 2352 } else if (operand->IsRegister()) { | 2352 } else if (operand->IsRegister()) { |
| 2353 __ push(ToRegister(operand)); | 2353 __ push(ToRegister(operand)); |
| 2354 } else { | 2354 } else { |
| 2355 __ push(ToOperand(operand)); | 2355 __ push(ToOperand(operand)); |
| 2356 } | 2356 } |
| 2357 } | 2357 } |
| 2358 | 2358 |
| 2359 | 2359 |
| 2360 // Check for cases where EmitLoadFieldOrConstantFunction needs to walk the |
| 2361 // prototype chain, which causes unbounded code generation. |
| 2362 static bool CompactEmit( |
| 2363 SmallMapList* list, Handle<String> name, int i, Isolate* isolate) { |
| 2364 LookupResult lookup(isolate); |
| 2365 Handle<Map> map = list->at(i); |
| 2366 map->LookupInDescriptors(NULL, *name, &lookup); |
| 2367 return lookup.IsFound() && |
| 2368 (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION); |
| 2369 } |
| 2370 |
| 2371 |
| 2360 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { | 2372 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
| 2361 Register object = ToRegister(instr->object()); | 2373 Register object = ToRegister(instr->object()); |
| 2362 Register result = ToRegister(instr->result()); | 2374 Register result = ToRegister(instr->result()); |
| 2363 | 2375 |
| 2364 int map_count = instr->hydrogen()->types()->length(); | 2376 int map_count = instr->hydrogen()->types()->length(); |
| 2365 bool need_generic = instr->hydrogen()->need_generic(); | 2377 bool need_generic = instr->hydrogen()->need_generic(); |
| 2366 | 2378 |
| 2367 if (map_count == 0 && !need_generic) { | 2379 if (map_count == 0 && !need_generic) { |
| 2368 DeoptimizeIf(no_condition, instr->environment()); | 2380 DeoptimizeIf(no_condition, instr->environment()); |
| 2369 return; | 2381 return; |
| 2370 } | 2382 } |
| 2371 Handle<String> name = instr->hydrogen()->name(); | 2383 Handle<String> name = instr->hydrogen()->name(); |
| 2372 Label done; | 2384 Label done; |
| 2373 bool compact_code = true; | 2385 bool all_are_compact = true; |
| 2374 for (int i = 0; i < map_count; ++i) { | 2386 for (int i = 0; i < map_count; ++i) { |
| 2375 LookupResult lookup(isolate()); | 2387 if (!CompactEmit(instr->hydrogen()->types(), name, i, isolate())) { |
| 2376 Handle<Map> map = instr->hydrogen()->types()->at(i); | 2388 all_are_compact = false; |
| 2377 map->LookupInDescriptors(NULL, *name, &lookup); | |
| 2378 if (!lookup.IsFound() || | |
| 2379 (lookup.type() != FIELD && lookup.type() != CONSTANT_FUNCTION)) { | |
| 2380 // The two cases above cause a bounded amount of code to be emitted. This | |
| 2381 // is not necessarily the case for other lookup results. | |
| 2382 compact_code = false; | |
| 2383 break; | 2389 break; |
| 2384 } | 2390 } |
| 2385 } | 2391 } |
| 2386 for (int i = 0; i < map_count; ++i) { | 2392 for (int i = 0; i < map_count; ++i) { |
| 2387 bool last = (i == map_count - 1); | 2393 bool last = (i == map_count - 1); |
| 2388 Handle<Map> map = instr->hydrogen()->types()->at(i); | 2394 Handle<Map> map = instr->hydrogen()->types()->at(i); |
| 2389 Label check_passed; | 2395 Label check_passed; |
| 2390 __ CompareMap(object, map, &check_passed, ALLOW_ELEMENT_TRANSITION_MAPS); | 2396 __ CompareMap(object, map, &check_passed, ALLOW_ELEMENT_TRANSITION_MAPS); |
| 2391 if (last && !need_generic) { | 2397 if (last && !need_generic) { |
| 2392 DeoptimizeIf(not_equal, instr->environment()); | 2398 DeoptimizeIf(not_equal, instr->environment()); |
| 2393 __ bind(&check_passed); | 2399 __ bind(&check_passed); |
| 2394 EmitLoadFieldOrConstantFunction( | 2400 EmitLoadFieldOrConstantFunction( |
| 2395 result, object, map, name, instr->environment()); | 2401 result, object, map, name, instr->environment()); |
| 2396 } else { | 2402 } else { |
| 2397 Label next; | 2403 Label next; |
| 2398 __ j(not_equal, &next, Label::kNear); | 2404 bool compact = |
| 2405 CompactEmit(instr->hydrogen()->types(), name, i, isolate()); |
| 2406 __ j(not_equal, &next, compact ? Label::kNear : Label::kFar); |
| 2399 __ bind(&check_passed); | 2407 __ bind(&check_passed); |
| 2400 EmitLoadFieldOrConstantFunction( | 2408 EmitLoadFieldOrConstantFunction( |
| 2401 result, object, map, name, instr->environment()); | 2409 result, object, map, name, instr->environment()); |
| 2402 __ jmp(&done, compact_code ? Label::kNear : Label::kFar); | 2410 __ jmp(&done, all_are_compact ? Label::kNear : Label::kFar); |
| 2403 __ bind(&next); | 2411 __ bind(&next); |
| 2404 } | 2412 } |
| 2405 } | 2413 } |
| 2406 if (need_generic) { | 2414 if (need_generic) { |
| 2407 __ mov(ecx, name); | 2415 __ mov(ecx, name); |
| 2408 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); | 2416 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2409 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2417 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 2410 } | 2418 } |
| 2411 __ bind(&done); | 2419 __ bind(&done); |
| 2412 } | 2420 } |
| (...skipping 2806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5219 FixedArray::kHeaderSize - kPointerSize)); | 5227 FixedArray::kHeaderSize - kPointerSize)); |
| 5220 __ bind(&done); | 5228 __ bind(&done); |
| 5221 } | 5229 } |
| 5222 | 5230 |
| 5223 | 5231 |
| 5224 #undef __ | 5232 #undef __ |
| 5225 | 5233 |
| 5226 } } // namespace v8::internal | 5234 } } // namespace v8::internal |
| 5227 | 5235 |
| 5228 #endif // V8_TARGET_ARCH_IA32 | 5236 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |