⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 heap.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
// Copyright 2006-2008 the V8 project authors. All rights reserved.// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are// met:////     * Redistributions of source code must retain the above copyright//       notice, this list of conditions and the following disclaimer.//     * Redistributions in binary form must reproduce the above//       copyright notice, this list of conditions and the following//       disclaimer in the documentation and/or other materials provided//       with the distribution.//     * Neither the name of Google Inc. nor the names of its//       contributors may be used to endorse or promote products derived//       from this software without specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#ifndef V8_HEAP_H_#define V8_HEAP_H_namespace v8 { namespace internal {// Defines all the roots in Heap.#define STRONG_ROOT_LIST(V)                             \  V(Map, meta_map)                                      \  V(Map, heap_number_map)                               \  V(Map, short_string_map)                              \  V(Map, medium_string_map)                             \  V(Map, long_string_map)                               \  V(Map, short_ascii_string_map)                        \  V(Map, medium_ascii_string_map)                       \  V(Map, long_ascii_string_map)                         \  V(Map, short_symbol_map)                              \  V(Map, medium_symbol_map)                             \  V(Map, long_symbol_map)                               \  V(Map, short_ascii_symbol_map)                        \  V(Map, medium_ascii_symbol_map)                       \  V(Map, long_ascii_symbol_map)                         \  V(Map, short_cons_symbol_map)                         \  V(Map, medium_cons_symbol_map)                        \  V(Map, long_cons_symbol_map)                          \  V(Map, short_cons_ascii_symbol_map)                   \  V(Map, medium_cons_ascii_symbol_map)                  \  V(Map, long_cons_ascii_symbol_map)                    \  V(Map, short_sliced_symbol_map)                       \  V(Map, medium_sliced_symbol_map)                      \  V(Map, long_sliced_symbol_map)                        \  V(Map, short_sliced_ascii_symbol_map)                 \  V(Map, medium_sliced_ascii_symbol_map)                \  V(Map, long_sliced_ascii_symbol_map)                  \  V(Map, short_external_symbol_map)                     \  V(Map, medium_external_symbol_map)                    \  V(Map, long_external_symbol_map)                      \  V(Map, short_external_ascii_symbol_map)               \  V(Map, medium_external_ascii_symbol_map)              \  V(Map, long_external_ascii_symbol_map)                \  V(Map, short_cons_string_map)                         \  V(Map, medium_cons_string_map)                        \  V(Map, long_cons_string_map)                          \  V(Map, short_cons_ascii_string_map)                   \  V(Map, medium_cons_ascii_string_map)                  \  V(Map, long_cons_ascii_string_map)                    \  V(Map, short_sliced_string_map)                       \  V(Map, medium_sliced_string_map)                      \  V(Map, long_sliced_string_map)                        \  V(Map, short_sliced_ascii_string_map)                 \  V(Map, medium_sliced_ascii_string_map)                \  V(Map, long_sliced_ascii_string_map)                  \  V(Map, short_external_string_map)                     \  V(Map, medium_external_string_map)                    \  V(Map, long_external_string_map)                      \  V(Map, short_external_ascii_string_map)               \  V(Map, medium_external_ascii_string_map)              \  V(Map, long_external_ascii_string_map)                \  V(Map, undetectable_short_string_map)                 \  V(Map, undetectable_medium_string_map)                \  V(Map, undetectable_long_string_map)                  \  V(Map, undetectable_short_ascii_string_map)           \  V(Map, undetectable_medium_ascii_string_map)          \  V(Map, undetectable_long_ascii_string_map)            \  V(Map, byte_array_map)                                \  V(Map, fixed_array_map)                               \  V(Map, hash_table_map)                                \  V(Map, context_map)                                   \  V(Map, global_context_map)                            \  V(Map, code_map)                                      \  V(Map, oddball_map)                                   \  V(Map, boilerplate_function_map)                      \  V(Map, shared_function_info_map)                      \  V(Map, proxy_map)                                     \  V(Map, one_word_filler_map)                           \  V(Map, two_word_filler_map)                           \  V(Object, nan_value)                                  \  V(Object, undefined_value)                            \  V(Object, minus_zero_value)                           \  V(Object, null_value)                                 \  V(Object, true_value)                                 \  V(Object, false_value)                                \  V(String, empty_string)                               \  V(FixedArray, empty_fixed_array)                      \  V(DescriptorArray, empty_descriptor_array)            \  V(Object, the_hole_value)                             \  V(Map, neander_map)                                   \  V(JSObject, message_listeners)                        \  V(Proxy, prototype_accessors)                         \  V(JSObject, debug_event_listeners)                    \  V(Dictionary, code_stubs)                             \  V(Dictionary, non_monomorphic_cache)                  \  V(Code, js_entry_code)                                \  V(Code, js_construct_entry_code)                      \  V(Code, c_entry_code)                                 \  V(Code, c_entry_debug_break_code)                     \  V(FixedArray, number_string_cache)                    \  V(FixedArray, single_character_string_cache)          \  V(FixedArray, natives_source_cache)#define ROOT_LIST(V)                                  \  STRONG_ROOT_LIST(V)                                 \  V(Object, symbol_table)#define SYMBOL_LIST(V)                                                   \  V(Array_symbol, "Array")                                               \  V(Object_symbol, "Object")                                             \  V(Proto_symbol, "__proto__")                                           \  V(StringImpl_symbol, "StringImpl")                                     \  V(arguments_symbol, "arguments")                                       \  V(arguments_shadow_symbol, ".arguments")                               \  V(call_symbol, "call")                                                 \  V(apply_symbol, "apply")                                               \  V(caller_symbol, "caller")                                             \  V(boolean_symbol, "boolean")                                           \  V(callee_symbol, "callee")                                             \  V(constructor_symbol, "constructor")                                   \  V(code_symbol, ".code")                                                \  V(result_symbol, ".result")                                            \  V(catch_var_symbol, ".catch-var")                                      \  V(finally_state_symbol, ".finally-state")                              \  V(empty_symbol, "")                                                    \  V(eval_symbol, "eval")                                                 \  V(function_symbol, "function")                                         \  V(length_symbol, "length")                                             \  V(name_symbol, "name")                                                 \  V(number_symbol, "number")                                             \  V(object_symbol, "object")                                             \  V(prototype_symbol, "prototype")                                       \  V(string_symbol, "string")                                             \  V(this_symbol, "this")                                                 \  V(to_string_symbol, "toString")                                        \  V(char_at_symbol, "CharAt")                                            \  V(undefined_symbol, "undefined")                                       \  V(value_of_symbol, "valueOf")                                          \  V(CreateObjectLiteralBoilerplate_symbol, "CreateObjectLiteralBoilerplate") \  V(CreateArrayLiteral_symbol, "CreateArrayLiteral")                     \  V(InitializeVarGlobal_symbol, "InitializeVarGlobal")                   \  V(InitializeConstGlobal_symbol, "InitializeConstGlobal")               \  V(stack_overflow_symbol, "kStackOverflowBoilerplate")                  \  V(illegal_access_symbol, "illegal access")                             \  V(out_of_memory_symbol, "out-of-memory")                               \  V(illegal_execution_state_symbol, "illegal execution state")           \  V(get_symbol, "get")                                                   \  V(set_symbol, "set")                                                   \  V(function_class_symbol, "Function")                                   \  V(illegal_argument_symbol, "illegal argument")                         \  V(MakeReferenceError_symbol, "MakeReferenceError")                     \  V(MakeSyntaxError_symbol, "MakeSyntaxError")                           \  V(MakeTypeError_symbol, "MakeTypeError")                               \  V(invalid_lhs_in_assignment_symbol, "invalid_lhs_in_assignment")       \  V(invalid_lhs_in_for_in_symbol, "invalid_lhs_in_for_in")               \  V(invalid_lhs_in_postfix_op_symbol, "invalid_lhs_in_postfix_op")       \  V(invalid_lhs_in_prefix_op_symbol, "invalid_lhs_in_prefix_op")         \  V(illegal_return_symbol, "illegal_return")                             \  V(illegal_break_symbol, "illegal_break")                               \  V(illegal_continue_symbol, "illegal_continue")                         \  V(unknown_label_symbol, "unknown_label")                               \  V(redeclaration_symbol, "redeclaration")                               \  V(failure_symbol, "<failure>")                                         \  V(space_symbol, " ")                                                   \  V(exec_symbol, "exec")                                                 \  V(zero_symbol, "0")// Forward declaration of the GCTracer class.class GCTracer;// The all static Heap captures the interface to the global object heap.// All JavaScript contexts by this process share the same object heap.class Heap : public AllStatic { public:  // Configure heap size before setup. Return false if the heap has been  // setup already.  static bool ConfigureHeap(int semispace_size, int old_gen_size);  static bool ConfigureHeapDefault();  // Initializes the global object heap. If create_heap_objects is true,  // also creates the basic non-mutable objects.  // Returns whether it succeeded.  static bool Setup(bool create_heap_objects);  // Destroys all memory allocated by the heap.  static void TearDown();  // Returns whether Setup has been called.  static bool HasBeenSetup();  // Returns the maximum heap capacity.  static int MaxCapacity() {    return young_generation_size_ + old_generation_size_;  }  static int SemiSpaceSize() { return semispace_size_; }  static int InitialSemiSpaceSize() { return initial_semispace_size_; }  static int YoungGenerationSize() { return young_generation_size_; }  static int OldGenerationSize() { return old_generation_size_; }  // Returns the capacity of the heap in bytes w/o growing. Heap grows when  // more spaces are needed until it reaches the limit.  static int Capacity();  // Returns the available bytes in space w/o growing.  // Heap doesn't guarantee that it can allocate an object that requires  // all available bytes. Check MaxHeapObjectSize() instead.  static int Available();  // Returns the maximum object size that heap supports. Objects larger than  // the maximum heap object size are allocated in a large object space.  static inline int MaxHeapObjectSize();  // Returns of size of all objects residing in the heap.  static int SizeOfObjects();  // Return the starting address and a mask for the new space.  And-masking an  // address with the mask will result in the start address of the new space  // for all addresses in either semispace.  static Address NewSpaceStart() { return new_space_->start(); }  static uint32_t NewSpaceMask() { return new_space_->mask(); }  static Address NewSpaceTop() { return new_space_->top(); }  static NewSpace* new_space() { return new_space_; }  static OldSpace* old_pointer_space() { return old_pointer_space_; }  static OldSpace* old_data_space() { return old_data_space_; }  static OldSpace* code_space() { return code_space_; }  static MapSpace* map_space() { return map_space_; }  static LargeObjectSpace* lo_space() { return lo_space_; }  static Address* NewSpaceAllocationTopAddress() {    return new_space_->allocation_top_address();  }  static Address* NewSpaceAllocationLimitAddress() {    return new_space_->allocation_limit_address();  }  // Allocates and initializes a new JavaScript object based on a  // constructor.  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation  // failed.  // Please note this does not perform a garbage collection.  static Object* AllocateJSObject(JSFunction* constructor,                                  PretenureFlag pretenure = NOT_TENURED);  // Allocates the function prototype.  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation  // failed.  // Please note this does not perform a garbage collection.  static Object* AllocateFunctionPrototype(JSFunction* function);  // Reinitialize a JSGlobalObject based on a constructor.  The JSObject  // must have the same size as objects allocated using the  // constructor.  The JSObject is reinitialized and behaves as an  // object that has been freshly allocated using the constructor.  static Object* ReinitializeJSGlobalObject(JSFunction* constructor,                                            JSGlobalObject* global);  // Allocates and initializes a new JavaScript object based on a map.  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation  // failed.  // Please note this does not perform a garbage collection.  static Object* AllocateJSObjectFromMap(Map* map,                                         PretenureFlag pretenure = NOT_TENURED);  // Allocates a heap object based on the map.  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation  // failed.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -