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

Side by Side Diff: src/objects.cc

Issue 15993016: Remove the optimized construct stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 6 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/objects.h ('k') | src/objects-inl.h » ('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 9629 matching lines...) Expand 10 before | Expand all | Expand 10 after
9640 } 9640 }
9641 return instance_size; 9641 return instance_size;
9642 } 9642 }
9643 9643
9644 9644
9645 int SharedFunctionInfo::CalculateInObjectProperties() { 9645 int SharedFunctionInfo::CalculateInObjectProperties() {
9646 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize; 9646 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize;
9647 } 9647 }
9648 9648
9649 9649
9650 bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) {
9651 // Check the basic conditions for generating inline constructor code.
9652 if (!FLAG_inline_new
9653 || !has_only_simple_this_property_assignments()
9654 || is_generator()
9655 || this_property_assignments_count() == 0) {
9656 return false;
9657 }
9658
9659 Isolate* isolate = GetIsolate();
9660 Heap* heap = isolate->heap();
9661
9662 // Traverse the proposed prototype chain looking for properties of the
9663 // same names as are set by the inline constructor.
9664 for (Object* obj = prototype;
9665 obj != heap->null_value();
9666 obj = obj->GetPrototype(isolate)) {
9667 JSReceiver* receiver = JSReceiver::cast(obj);
9668 for (int i = 0; i < this_property_assignments_count(); i++) {
9669 LookupResult result(heap->isolate());
9670 String* name = GetThisPropertyAssignmentName(i);
9671 receiver->LocalLookup(name, &result);
9672 if (result.IsFound()) {
9673 switch (result.type()) {
9674 case NORMAL:
9675 case FIELD:
9676 case CONSTANT_FUNCTION:
9677 break;
9678 case INTERCEPTOR:
9679 case CALLBACKS:
9680 case HANDLER:
9681 return false;
9682 case TRANSITION:
9683 case NONEXISTENT:
9684 UNREACHABLE();
9685 break;
9686 }
9687 }
9688 }
9689 }
9690
9691 return true;
9692 }
9693
9694
9695 void SharedFunctionInfo::ForbidInlineConstructor() {
9696 set_compiler_hints(BooleanBit::set(compiler_hints(),
9697 kHasOnlySimpleThisPropertyAssignments,
9698 false));
9699 }
9700
9701
9702 void SharedFunctionInfo::SetThisPropertyAssignmentsInfo(
9703 bool only_simple_this_property_assignments,
9704 FixedArray* assignments) {
9705 set_compiler_hints(BooleanBit::set(compiler_hints(),
9706 kHasOnlySimpleThisPropertyAssignments,
9707 only_simple_this_property_assignments));
9708 set_this_property_assignments(assignments);
9709 set_this_property_assignments_count(assignments->length() / 3);
9710 }
9711
9712
9713 void SharedFunctionInfo::ClearThisPropertyAssignmentsInfo() {
9714 Heap* heap = GetHeap();
9715 set_compiler_hints(BooleanBit::set(compiler_hints(),
9716 kHasOnlySimpleThisPropertyAssignments,
9717 false));
9718 set_this_property_assignments(heap->undefined_value());
9719 set_this_property_assignments_count(0);
9720 }
9721
9722
9723 String* SharedFunctionInfo::GetThisPropertyAssignmentName(int index) {
9724 Object* obj = this_property_assignments();
9725 ASSERT(obj->IsFixedArray());
9726 ASSERT(index < this_property_assignments_count());
9727 obj = FixedArray::cast(obj)->get(index * 3);
9728 ASSERT(obj->IsString());
9729 return String::cast(obj);
9730 }
9731
9732
9733 bool SharedFunctionInfo::IsThisPropertyAssignmentArgument(int index) {
9734 Object* obj = this_property_assignments();
9735 ASSERT(obj->IsFixedArray());
9736 ASSERT(index < this_property_assignments_count());
9737 obj = FixedArray::cast(obj)->get(index * 3 + 1);
9738 return Smi::cast(obj)->value() != -1;
9739 }
9740
9741
9742 int SharedFunctionInfo::GetThisPropertyAssignmentArgument(int index) {
9743 ASSERT(IsThisPropertyAssignmentArgument(index));
9744 Object* obj =
9745 FixedArray::cast(this_property_assignments())->get(index * 3 + 1);
9746 return Smi::cast(obj)->value();
9747 }
9748
9749
9750 Object* SharedFunctionInfo::GetThisPropertyAssignmentConstant(int index) {
9751 ASSERT(!IsThisPropertyAssignmentArgument(index));
9752 Object* obj =
9753 FixedArray::cast(this_property_assignments())->get(index * 3 + 2);
9754 return obj;
9755 }
9756
9757
9758 // Support function for printing the source code to a StringStream 9650 // Support function for printing the source code to a StringStream
9759 // without any allocation in the heap. 9651 // without any allocation in the heap.
9760 void SharedFunctionInfo::SourceCodePrint(StringStream* accumulator, 9652 void SharedFunctionInfo::SourceCodePrint(StringStream* accumulator,
9761 int max_length) { 9653 int max_length) {
9762 // For some native functions there is no source. 9654 // For some native functions there is no source.
9763 if (!HasSourceCode()) { 9655 if (!HasSourceCode()) {
9764 accumulator->Add("<No Source>"); 9656 accumulator->Add("<No Source>");
9765 return; 9657 return;
9766 } 9658 }
9767 9659
(...skipping 5912 matching lines...) Expand 10 before | Expand all | Expand 10 after
15680 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 15572 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
15681 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 15573 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
15682 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 15574 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
15683 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 15575 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
15684 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 15576 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
15685 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 15577 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
15686 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 15578 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
15687 } 15579 }
15688 15580
15689 } } // namespace v8::internal 15581 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698