OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 4762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4773 Object* SharedFunctionInfo::GetSourceCode() { | 4773 Object* SharedFunctionInfo::GetSourceCode() { |
4774 HandleScope scope; | 4774 HandleScope scope; |
4775 if (script()->IsUndefined()) return Heap::undefined_value(); | 4775 if (script()->IsUndefined()) return Heap::undefined_value(); |
4776 Object* source = Script::cast(script())->source(); | 4776 Object* source = Script::cast(script())->source(); |
4777 if (source->IsUndefined()) return Heap::undefined_value(); | 4777 if (source->IsUndefined()) return Heap::undefined_value(); |
4778 return *SubString(Handle<String>(String::cast(source)), | 4778 return *SubString(Handle<String>(String::cast(source)), |
4779 start_position(), end_position()); | 4779 start_position(), end_position()); |
4780 } | 4780 } |
4781 | 4781 |
4782 | 4782 |
| 4783 int SharedFunctionInfo::CalculateInstanceSize() { |
| 4784 int instance_size = |
| 4785 JSObject::kHeaderSize + |
| 4786 expected_nof_properties() * kPointerSize; |
| 4787 if (instance_size > JSObject::kMaxInstanceSize) { |
| 4788 instance_size = JSObject::kMaxInstanceSize; |
| 4789 } |
| 4790 return instance_size; |
| 4791 } |
| 4792 |
| 4793 |
| 4794 int SharedFunctionInfo::CalculateInObjectProperties() { |
| 4795 return (CalculateInstanceSize() - JSObject::kHeaderSize) / kPointerSize; |
| 4796 } |
| 4797 |
| 4798 |
| 4799 void SharedFunctionInfo::SetThisPropertyAssignmentsInfo( |
| 4800 bool only_this_property_assignments, |
| 4801 bool only_simple_this_property_assignments, |
| 4802 FixedArray* assignments) { |
| 4803 ASSERT(this_property_assignments()->IsUndefined()); |
| 4804 set_compiler_hints(BooleanBit::set(compiler_hints(), |
| 4805 kHasOnlyThisPropertyAssignments, |
| 4806 only_this_property_assignments)); |
| 4807 set_compiler_hints(BooleanBit::set(compiler_hints(), |
| 4808 kHasOnlySimpleThisPropertyAssignments, |
| 4809 only_simple_this_property_assignments)); |
| 4810 set_this_property_assignments(assignments); |
| 4811 set_this_property_assignments_count(assignments->length() / 3); |
| 4812 } |
| 4813 |
| 4814 |
| 4815 String* SharedFunctionInfo::GetThisPropertyAssignmentName(int index) { |
| 4816 Object* obj = this_property_assignments(); |
| 4817 ASSERT(obj->IsFixedArray()); |
| 4818 ASSERT(index < this_property_assignments_count()); |
| 4819 obj = FixedArray::cast(obj)->get(index * 3); |
| 4820 ASSERT(obj->IsString()); |
| 4821 return String::cast(obj); |
| 4822 } |
| 4823 |
| 4824 |
4783 // Support function for printing the source code to a StringStream | 4825 // Support function for printing the source code to a StringStream |
4784 // without any allocation in the heap. | 4826 // without any allocation in the heap. |
4785 void SharedFunctionInfo::SourceCodePrint(StringStream* accumulator, | 4827 void SharedFunctionInfo::SourceCodePrint(StringStream* accumulator, |
4786 int max_length) { | 4828 int max_length) { |
4787 // For some native functions there is no source. | 4829 // For some native functions there is no source. |
4788 if (script()->IsUndefined() || | 4830 if (script()->IsUndefined() || |
4789 Script::cast(script())->source()->IsUndefined()) { | 4831 Script::cast(script())->source()->IsUndefined()) { |
4790 accumulator->Add("<No Source>"); | 4832 accumulator->Add("<No Source>"); |
4791 return; | 4833 return; |
4792 } | 4834 } |
(...skipping 26 matching lines...) Expand all Loading... |
4819 } else { | 4861 } else { |
4820 accumulator->Put(script_source, start_position(), end_position()); | 4862 accumulator->Put(script_source, start_position(), end_position()); |
4821 } | 4863 } |
4822 } | 4864 } |
4823 | 4865 |
4824 | 4866 |
4825 void SharedFunctionInfo::SharedFunctionInfoIterateBody(ObjectVisitor* v) { | 4867 void SharedFunctionInfo::SharedFunctionInfoIterateBody(ObjectVisitor* v) { |
4826 IteratePointers(v, kNameOffset, kConstructStubOffset + kPointerSize); | 4868 IteratePointers(v, kNameOffset, kConstructStubOffset + kPointerSize); |
4827 IteratePointers(v, kInstanceClassNameOffset, kScriptOffset + kPointerSize); | 4869 IteratePointers(v, kInstanceClassNameOffset, kScriptOffset + kPointerSize); |
4828 IteratePointers(v, kDebugInfoOffset, kInferredNameOffset + kPointerSize); | 4870 IteratePointers(v, kDebugInfoOffset, kInferredNameOffset + kPointerSize); |
| 4871 IteratePointers(v, kThisPropertyAssignmentsOffset, |
| 4872 kThisPropertyAssignmentsOffset + kPointerSize); |
4829 } | 4873 } |
4830 | 4874 |
4831 | 4875 |
4832 void ObjectVisitor::BeginCodeIteration(Code* code) { | 4876 void ObjectVisitor::BeginCodeIteration(Code* code) { |
4833 ASSERT(code->ic_flag() == Code::IC_TARGET_IS_OBJECT); | 4877 ASSERT(code->ic_flag() == Code::IC_TARGET_IS_OBJECT); |
4834 } | 4878 } |
4835 | 4879 |
4836 | 4880 |
4837 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { | 4881 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { |
4838 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); | 4882 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); |
(...skipping 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7904 if (break_point_objects()->IsUndefined()) return 0; | 7948 if (break_point_objects()->IsUndefined()) return 0; |
7905 // Single beak point. | 7949 // Single beak point. |
7906 if (!break_point_objects()->IsFixedArray()) return 1; | 7950 if (!break_point_objects()->IsFixedArray()) return 1; |
7907 // Multiple break points. | 7951 // Multiple break points. |
7908 return FixedArray::cast(break_point_objects())->length(); | 7952 return FixedArray::cast(break_point_objects())->length(); |
7909 } | 7953 } |
7910 #endif | 7954 #endif |
7911 | 7955 |
7912 | 7956 |
7913 } } // namespace v8::internal | 7957 } } // namespace v8::internal |
OLD | NEW |