OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 if (!maybe_elements->ToObject(&elements)) return false; | 1899 if (!maybe_elements->ToObject(&elements)) return false; |
1900 } | 1900 } |
1901 FixedArray::cast(elements)->set(0, Smi::FromInt(0)); | 1901 FixedArray::cast(elements)->set(0, Smi::FromInt(0)); |
1902 JSObject::cast(obj)->set_elements(FixedArray::cast(elements)); | 1902 JSObject::cast(obj)->set_elements(FixedArray::cast(elements)); |
1903 set_message_listeners(JSObject::cast(obj)); | 1903 set_message_listeners(JSObject::cast(obj)); |
1904 | 1904 |
1905 return true; | 1905 return true; |
1906 } | 1906 } |
1907 | 1907 |
1908 | 1908 |
1909 void Heap::CreateCEntryStub() { | |
1910 CEntryStub stub(1); | |
1911 set_c_entry_code(*stub.GetCode()); | |
1912 } | |
1913 | |
1914 | |
1915 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP | |
1916 void Heap::CreateRegExpCEntryStub() { | |
1917 RegExpCEntryStub stub; | |
1918 set_re_c_entry_code(*stub.GetCode()); | |
1919 } | |
1920 #endif | |
1921 | |
1922 | |
1923 void Heap::CreateJSEntryStub() { | 1909 void Heap::CreateJSEntryStub() { |
1924 JSEntryStub stub; | 1910 JSEntryStub stub; |
1925 set_js_entry_code(*stub.GetCode()); | 1911 set_js_entry_code(*stub.GetCode()); |
1926 } | 1912 } |
1927 | 1913 |
1928 | 1914 |
1929 void Heap::CreateJSConstructEntryStub() { | 1915 void Heap::CreateJSConstructEntryStub() { |
1930 JSConstructEntryStub stub; | 1916 JSConstructEntryStub stub; |
1931 set_js_construct_entry_code(*stub.GetCode()); | 1917 set_js_construct_entry_code(*stub.GetCode()); |
1932 } | 1918 } |
1933 | 1919 |
1934 | 1920 |
1935 #if V8_TARGET_ARCH_ARM | |
1936 void Heap::CreateDirectCEntryStub() { | |
1937 DirectCEntryStub stub; | |
1938 set_direct_c_entry_code(*stub.GetCode()); | |
1939 } | |
1940 #endif | |
1941 | |
1942 | |
1943 void Heap::CreateFixedStubs() { | 1921 void Heap::CreateFixedStubs() { |
1944 // Here we create roots for fixed stubs. They are needed at GC | 1922 // Here we create roots for fixed stubs. They are needed at GC |
1945 // for cooking and uncooking (check out frames.cc). | 1923 // for cooking and uncooking (check out frames.cc). |
1946 // The eliminates the need for doing dictionary lookup in the | 1924 // The eliminates the need for doing dictionary lookup in the |
1947 // stub cache for these stubs. | 1925 // stub cache for these stubs. |
1948 HandleScope scope; | 1926 HandleScope scope; |
1949 // gcc-4.4 has problem generating correct code of following snippet: | 1927 // gcc-4.4 has problem generating correct code of following snippet: |
1950 // { CEntryStub stub; | 1928 // { JSEntryStub stub; |
1951 // c_entry_code_ = *stub.GetCode(); | 1929 // js_entry_code_ = *stub.GetCode(); |
1952 // } | 1930 // } |
1953 // { DebuggerStatementStub stub; | 1931 // { JSConstructEntryStub stub; |
1954 // debugger_statement_code_ = *stub.GetCode(); | 1932 // js_construct_entry_code_ = *stub.GetCode(); |
1955 // } | 1933 // } |
1956 // To workaround the problem, make separate functions without inlining. | 1934 // To workaround the problem, make separate functions without inlining. |
1957 Heap::CreateCEntryStub(); | |
1958 Heap::CreateJSEntryStub(); | 1935 Heap::CreateJSEntryStub(); |
1959 Heap::CreateJSConstructEntryStub(); | 1936 Heap::CreateJSConstructEntryStub(); |
1960 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP | |
1961 Heap::CreateRegExpCEntryStub(); | |
1962 #endif | |
1963 #if V8_TARGET_ARCH_ARM | |
1964 Heap::CreateDirectCEntryStub(); | |
1965 #endif | |
1966 } | 1937 } |
1967 | 1938 |
1968 | 1939 |
1969 bool Heap::CreateInitialObjects() { | 1940 bool Heap::CreateInitialObjects() { |
1970 Object* obj; | 1941 Object* obj; |
1971 | 1942 |
1972 // The -0 value must be set before NumberFromDouble works. | 1943 // The -0 value must be set before NumberFromDouble works. |
1973 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED); | 1944 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED); |
1974 if (!maybe_obj->ToObject(&obj)) return false; | 1945 if (!maybe_obj->ToObject(&obj)) return false; |
1975 } | 1946 } |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 reinterpret_cast<ExternalArray*>(result)->set_length(length); | 2697 reinterpret_cast<ExternalArray*>(result)->set_length(length); |
2727 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( | 2698 reinterpret_cast<ExternalArray*>(result)->set_external_pointer( |
2728 external_pointer); | 2699 external_pointer); |
2729 | 2700 |
2730 return result; | 2701 return result; |
2731 } | 2702 } |
2732 | 2703 |
2733 | 2704 |
2734 MaybeObject* Heap::CreateCode(const CodeDesc& desc, | 2705 MaybeObject* Heap::CreateCode(const CodeDesc& desc, |
2735 Code::Flags flags, | 2706 Code::Flags flags, |
2736 Handle<Object> self_reference) { | 2707 Handle<Object> self_reference, |
| 2708 bool immovable) { |
2737 // Allocate ByteArray before the Code object, so that we do not risk | 2709 // Allocate ByteArray before the Code object, so that we do not risk |
2738 // leaving uninitialized Code object (and breaking the heap). | 2710 // leaving uninitialized Code object (and breaking the heap). |
2739 Object* reloc_info; | 2711 Object* reloc_info; |
2740 { MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED); | 2712 { MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED); |
2741 if (!maybe_reloc_info->ToObject(&reloc_info)) return maybe_reloc_info; | 2713 if (!maybe_reloc_info->ToObject(&reloc_info)) return maybe_reloc_info; |
2742 } | 2714 } |
2743 | 2715 |
2744 // Compute size | 2716 // Compute size. |
2745 int body_size = RoundUp(desc.instr_size, kObjectAlignment); | 2717 int body_size = RoundUp(desc.instr_size, kObjectAlignment); |
2746 int obj_size = Code::SizeFor(body_size); | 2718 int obj_size = Code::SizeFor(body_size); |
2747 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); | 2719 ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); |
2748 MaybeObject* maybe_result; | 2720 MaybeObject* maybe_result; |
2749 if (obj_size > MaxObjectSizeInPagedSpace()) { | 2721 // Large code objects and code objects which should stay at a fixed address |
| 2722 // are allocated in large object space. |
| 2723 if (obj_size > MaxObjectSizeInPagedSpace() || immovable) { |
2750 maybe_result = lo_space_->AllocateRawCode(obj_size); | 2724 maybe_result = lo_space_->AllocateRawCode(obj_size); |
2751 } else { | 2725 } else { |
2752 maybe_result = code_space_->AllocateRaw(obj_size); | 2726 maybe_result = code_space_->AllocateRaw(obj_size); |
2753 } | 2727 } |
2754 | 2728 |
2755 Object* result; | 2729 Object* result; |
2756 if (!maybe_result->ToObject(&result)) return maybe_result; | 2730 if (!maybe_result->ToObject(&result)) return maybe_result; |
2757 | 2731 |
2758 // Initialize the object | 2732 // Initialize the object |
2759 HeapObject::cast(result)->set_map(code_map()); | 2733 HeapObject::cast(result)->set_map(code_map()); |
(...skipping 2841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5601 void ExternalStringTable::TearDown() { | 5575 void ExternalStringTable::TearDown() { |
5602 new_space_strings_.Free(); | 5576 new_space_strings_.Free(); |
5603 old_space_strings_.Free(); | 5577 old_space_strings_.Free(); |
5604 } | 5578 } |
5605 | 5579 |
5606 | 5580 |
5607 List<Object*> ExternalStringTable::new_space_strings_; | 5581 List<Object*> ExternalStringTable::new_space_strings_; |
5608 List<Object*> ExternalStringTable::old_space_strings_; | 5582 List<Object*> ExternalStringTable::old_space_strings_; |
5609 | 5583 |
5610 } } // namespace v8::internal | 5584 } } // namespace v8::internal |
OLD | NEW |