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

Side by Side Diff: src/hydrogen.cc

Issue 138443012: Reland ArrayPop / ArrayPush. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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/stub-cache-arm.cc ('k') | src/ia32/code-stubs-ia32.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 7594 matching lines...) Expand 10 before | Expand all | Expand 10 after
7605 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { 7605 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
7606 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 7606 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7607 HValue* right = Pop(); 7607 HValue* right = Pop();
7608 HValue* left = Pop(); 7608 HValue* left = Pop();
7609 Drop(1); // Receiver. 7609 Drop(1); // Receiver.
7610 HInstruction* result = HMul::NewImul(zone(), context(), left, right); 7610 HInstruction* result = HMul::NewImul(zone(), context(), left, right);
7611 ast_context()->ReturnInstruction(result, expr->id()); 7611 ast_context()->ReturnInstruction(result, expr->id());
7612 return true; 7612 return true;
7613 } 7613 }
7614 break; 7614 break;
7615 case kArrayPop: {
7616 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) {
7617 return false;
7618 }
7619 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
7620 ElementsKind elements_kind = receiver_map->elements_kind();
7621 if (!IsFastElementsKind(elements_kind)) return false;
7622 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7623
7624 Drop(expr->arguments()->length());
7625 HValue* result;
7626 HValue* checked_object;
7627 HValue* reduced_length;
7628 HValue* receiver = Pop();
7629 { NoObservableSideEffectsScope scope(this);
7630 checked_object = AddCheckMap(receiver, receiver_map);
7631 HValue* elements = AddLoadElements(checked_object);
7632 // Ensure that we aren't popping from a copy-on-write array.
7633 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
7634 Add<HCheckMaps>(
7635 elements, isolate()->factory()->fixed_array_map(), top_info());
7636 }
7637 HValue* length = Add<HLoadNamedField>(
7638 checked_object, HObjectAccess::ForArrayLength(elements_kind));
7639 reduced_length = AddUncasted<HSub>(length, graph()->GetConstant1());
7640 HValue* bounds_check = Add<HBoundsCheck>(
7641 graph()->GetConstant0(), length);
7642 result = AddElementAccess(elements, reduced_length, NULL,
7643 bounds_check, elements_kind, false);
7644 Factory* factory = isolate()->factory();
7645 double nan_double = FixedDoubleArray::hole_nan_as_double();
7646 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind)
7647 ? Add<HConstant>(factory->the_hole_value())
7648 : Add<HConstant>(nan_double);
7649 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
7650 elements_kind = FAST_HOLEY_ELEMENTS;
7651 }
7652 AddElementAccess(
7653 elements, reduced_length, hole, bounds_check, elements_kind, true);
7654 }
7655 Add<HStoreNamedField>(
7656 checked_object, HObjectAccess::ForArrayLength(elements_kind),
7657 reduced_length);
7658 if (!ast_context()->IsEffect()) Push(result);
7659 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE);
7660 if (!ast_context()->IsEffect()) Drop(1);
7661 ast_context()->ReturnValue(result);
7662 return true;
7663 }
7664 case kArrayPush: {
7665 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) {
7666 return false;
7667 }
7668 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
7669 ElementsKind elements_kind = receiver_map->elements_kind();
7670 if (!IsFastElementsKind(elements_kind)) return false;
7671 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7672
7673 HValue* op_vals[] = {
7674 context(),
7675 // Receiver.
7676 environment()->ExpressionStackAt(expr->arguments()->length())
7677 };
7678
7679 const int argc = expr->arguments()->length();
7680 // Includes receiver.
7681 PushArgumentsFromEnvironment(argc + 1);
7682
7683 CallInterfaceDescriptor* descriptor =
7684 isolate()->call_descriptor(Isolate::CallHandler);
7685
7686 ArrayPushStub stub(receiver_map->elements_kind(), argc);
7687 Handle<Code> code = stub.GetCode(isolate());
7688 HConstant* code_value = Add<HConstant>(code);
7689
7690 ASSERT((sizeof(op_vals) / kPointerSize) ==
7691 descriptor->environment_length());
7692
7693 HInstruction* call = New<HCallWithDescriptor>(
7694 code_value, argc + 1, descriptor,
7695 Vector<HValue*>(op_vals, descriptor->environment_length()));
7696 ast_context()->ReturnInstruction(call, expr->id());
7697 return true;
7698 }
7615 default: 7699 default:
7616 // Not yet supported for inlining. 7700 // Not yet supported for inlining.
7617 break; 7701 break;
7618 } 7702 }
7619 return false; 7703 return false;
7620 } 7704 }
7621 7705
7622 7706
7623 bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { 7707 bool HOptimizedGraphBuilder::TryCallApply(Call* expr) {
7624 Expression* callee = expr->expression(); 7708 Expression* callee = expr->expression();
(...skipping 3374 matching lines...) Expand 10 before | Expand all | Expand 10 after
10999 if (ShouldProduceTraceOutput()) { 11083 if (ShouldProduceTraceOutput()) {
11000 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11084 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11001 } 11085 }
11002 11086
11003 #ifdef DEBUG 11087 #ifdef DEBUG
11004 graph_->Verify(false); // No full verify. 11088 graph_->Verify(false); // No full verify.
11005 #endif 11089 #endif
11006 } 11090 }
11007 11091
11008 } } // namespace v8::internal 11092 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698