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

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 12385014: Hydrogen stubs for array constructors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More efficient code when number of arguments is known Created 7 years, 8 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
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 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 2284
2285 if (instr->value()->representation().IsDouble()) { 2285 if (instr->value()->representation().IsDouble()) {
2286 LOperand* object = UseRegisterAtStart(instr->elements()); 2286 LOperand* object = UseRegisterAtStart(instr->elements());
2287 LOperand* val = NULL; 2287 LOperand* val = NULL;
2288 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { 2288 if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
2289 val = UseRegisterAtStart(instr->value()); 2289 val = UseRegisterAtStart(instr->value());
2290 } else if (!instr->IsConstantHoleStore()) { 2290 } else if (!instr->IsConstantHoleStore()) {
2291 val = UseX87TopOfStack(instr->value()); 2291 val = UseX87TopOfStack(instr->value());
2292 } 2292 }
2293 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); 2293 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2294
2295 return new(zone()) LStoreKeyed(object, key, val); 2294 return new(zone()) LStoreKeyed(object, key, val);
2296 } else { 2295 } else {
2297 ASSERT(instr->value()->representation().IsTagged()); 2296 ASSERT(instr->value()->representation().IsTagged());
2298 bool needs_write_barrier = instr->NeedsWriteBarrier(); 2297 bool needs_write_barrier = instr->NeedsWriteBarrier();
2299 2298
2300 LOperand* obj = UseRegister(instr->elements()); 2299 LOperand* obj = UseRegister(instr->elements());
2301 LOperand* val = needs_write_barrier 2300 LOperand* val;
2302 ? UseTempRegister(instr->value()) 2301 LOperand* key;
2303 : UseRegisterAtStart(instr->value()); 2302 if (needs_write_barrier) {
2304 LOperand* key = needs_write_barrier 2303 val = UseTempRegister(instr->value());
2305 ? UseTempRegister(instr->key()) 2304 key = UseTempRegister(instr->key());
2306 : UseRegisterOrConstantAtStart(instr->key()); 2305 } else {
2306 val = UseRegisterOrConstantAtStart(instr->value());
2307 key = UseRegisterOrConstantAtStart(instr->key());
2308 }
2307 return new(zone()) LStoreKeyed(obj, key, val); 2309 return new(zone()) LStoreKeyed(obj, key, val);
2308 } 2310 }
2309 } 2311 }
2310 2312
2311 ElementsKind elements_kind = instr->elements_kind(); 2313 ElementsKind elements_kind = instr->elements_kind();
2312 ASSERT( 2314 ASSERT(
2313 (instr->value()->representation().IsInteger32() && 2315 (instr->value()->representation().IsInteger32() &&
2314 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && 2316 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
2315 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || 2317 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
2316 (instr->value()->representation().IsDouble() && 2318 (instr->value()->representation().IsDouble() &&
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 if (needs_write_barrier) { 2398 if (needs_write_barrier) {
2397 obj = instr->is_in_object() 2399 obj = instr->is_in_object()
2398 ? UseRegister(instr->object()) 2400 ? UseRegister(instr->object())
2399 : UseTempRegister(instr->object()); 2401 : UseTempRegister(instr->object());
2400 } else { 2402 } else {
2401 obj = needs_write_barrier_for_map 2403 obj = needs_write_barrier_for_map
2402 ? UseRegister(instr->object()) 2404 ? UseRegister(instr->object())
2403 : UseRegisterAtStart(instr->object()); 2405 : UseRegisterAtStart(instr->object());
2404 } 2406 }
2405 2407
2406 LOperand* val = needs_write_barrier 2408 LOperand* val = NULL;
2407 ? UseTempRegister(instr->value()) 2409 if (needs_write_barrier) {
2408 : UseRegister(instr->value()); 2410 val = UseTempRegister(instr->value());
2411 } else if (instr->value()->IsConstant()) {
2412 // If it's tagged, it might still be in new space
2413 HConstant* constant_value = HConstant::cast(instr->value());
2414 if (constant_value->HasInteger32Value() ||
2415 constant_value->HasDoubleValue() ||
2416 constant_value->ImmortalImmovable()) {
2417 val = UseRegisterOrConstant(instr->value());
2418 }
2419 }
2420
2421 if (val == NULL) {
2422 val = UseRegister(instr->value());
2423 }
2409 2424
2410 // We only need a scratch register if we have a write barrier or we 2425 // We only need a scratch register if we have a write barrier or we
2411 // have a store into the properties array (not in-object-property). 2426 // have a store into the properties array (not in-object-property).
2412 LOperand* temp = (!instr->is_in_object() || needs_write_barrier || 2427 LOperand* temp = (!instr->is_in_object() || needs_write_barrier ||
2413 needs_write_barrier_for_map) ? TempRegister() : NULL; 2428 needs_write_barrier_for_map) ? TempRegister() : NULL;
2414 2429
2415 // We need a temporary register for write barrier of the map field. 2430 // We need a temporary register for write barrier of the map field.
2416 LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL; 2431 LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL;
2417 2432
2418 return new(zone()) LStoreNamedField(obj, val, temp, temp_map); 2433 return new(zone()) LStoreNamedField(obj, val, temp, temp_map);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 LOperand* context = UseAny(instr->context()); 2484 LOperand* context = UseAny(instr->context());
2470 LOperand* temp = TempRegister(); 2485 LOperand* temp = TempRegister();
2471 LAllocateObject* result = new(zone()) LAllocateObject(context, temp); 2486 LAllocateObject* result = new(zone()) LAllocateObject(context, temp);
2472 return AssignPointerMap(DefineAsRegister(result)); 2487 return AssignPointerMap(DefineAsRegister(result));
2473 } 2488 }
2474 2489
2475 2490
2476 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { 2491 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
2477 info()->MarkAsDeferredCalling(); 2492 info()->MarkAsDeferredCalling();
2478 LOperand* context = UseAny(instr->context()); 2493 LOperand* context = UseAny(instr->context());
2494 // TODO(mvstanton): why can't size be a constant if possible?
2479 LOperand* size = UseTempRegister(instr->size()); 2495 LOperand* size = UseTempRegister(instr->size());
2480 LOperand* temp = TempRegister(); 2496 LOperand* temp = TempRegister();
2481 LAllocate* result = new(zone()) LAllocate(context, size, temp); 2497 LAllocate* result = new(zone()) LAllocate(context, size, temp);
2482 return AssignPointerMap(DefineAsRegister(result)); 2498 return AssignPointerMap(DefineAsRegister(result));
2483 } 2499 }
2484 2500
2485 2501
2486 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { 2502 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) {
2487 LOperand* context = UseFixed(instr->context(), esi); 2503 LOperand* context = UseFixed(instr->context(), esi);
2488 return MarkAsCall( 2504 return MarkAsCall(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 2546
2531 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { 2547 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2532 LParameter* result = new(zone()) LParameter; 2548 LParameter* result = new(zone()) LParameter;
2533 if (instr->kind() == HParameter::STACK_PARAMETER) { 2549 if (instr->kind() == HParameter::STACK_PARAMETER) {
2534 int spill_index = chunk()->GetParameterStackSlot(instr->index()); 2550 int spill_index = chunk()->GetParameterStackSlot(instr->index());
2535 return DefineAsSpilled(result, spill_index); 2551 return DefineAsSpilled(result, spill_index);
2536 } else { 2552 } else {
2537 ASSERT(info()->IsStub()); 2553 ASSERT(info()->IsStub());
2538 CodeStubInterfaceDescriptor* descriptor = 2554 CodeStubInterfaceDescriptor* descriptor =
2539 info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); 2555 info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
2540 Register reg = descriptor->register_params_[instr->index()]; 2556 Register reg;
2557 if (static_cast<int>(instr->index()) == descriptor->register_param_count_) {
2558 reg = *(descriptor->stack_parameter_count_);
2559 } else {
2560 reg = descriptor->register_params_[instr->index()];
2561 }
2541 return DefineFixed(result, reg); 2562 return DefineFixed(result, reg);
2542 } 2563 }
2543 } 2564 }
2544 2565
2545 2566
2546 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { 2567 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2547 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. 2568 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width.
2548 if (spill_index > LUnallocated::kMaxFixedIndex) { 2569 if (spill_index > LUnallocated::kMaxFixedIndex) {
2549 Abort("Too many spill slots needed for OSR"); 2570 Abort("Too many spill slots needed for OSR");
2550 spill_index = 0; 2571 spill_index = 0;
(...skipping 14 matching lines...) Expand all
2565 // There are no real uses of the arguments object. 2586 // There are no real uses of the arguments object.
2566 // arguments.length and element access are supported directly on 2587 // arguments.length and element access are supported directly on
2567 // stack arguments, and any real arguments object use causes a bailout. 2588 // stack arguments, and any real arguments object use causes a bailout.
2568 // So this value is never used. 2589 // So this value is never used.
2569 return NULL; 2590 return NULL;
2570 } 2591 }
2571 2592
2572 2593
2573 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { 2594 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2574 LOperand* args = UseRegister(instr->arguments()); 2595 LOperand* args = UseRegister(instr->arguments());
2575 LOperand* length = UseTempRegister(instr->length()); 2596 LOperand* length;
2576 LOperand* index = Use(instr->index()); 2597 LOperand* index;
2598 if (instr->length()->IsConstant() && instr->index()->IsConstant()) {
2599 length = UseRegisterOrConstant(instr->length());
2600 index = UseOrConstant(instr->index());
2601 } else {
2602 length = UseTempRegister(instr->length());
2603 index = Use(instr->index());
2604 }
2577 return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index)); 2605 return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index));
2578 } 2606 }
2579 2607
2580 2608
2581 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) { 2609 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2582 LOperand* object = UseFixed(instr->value(), eax); 2610 LOperand* object = UseFixed(instr->value(), eax);
2583 LToFastProperties* result = new(zone()) LToFastProperties(object); 2611 LToFastProperties* result = new(zone()) LToFastProperties(object);
2584 return MarkAsCall(DefineFixed(result, eax), instr); 2612 return MarkAsCall(DefineFixed(result, eax), instr);
2585 } 2613 }
2586 2614
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2752 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2725 LOperand* object = UseRegister(instr->object()); 2753 LOperand* object = UseRegister(instr->object());
2726 LOperand* index = UseTempRegister(instr->index()); 2754 LOperand* index = UseTempRegister(instr->index());
2727 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2755 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2728 } 2756 }
2729 2757
2730 2758
2731 } } // namespace v8::internal 2759 } } // namespace v8::internal
2732 2760
2733 #endif // V8_TARGET_ARCH_IA32 2761 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698