From 8faa5f9abc4b4bdc127607cd9dde70a1b8e22add Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Tue, 5 Apr 2022 21:28:18 +0800 Subject: [PATCH] [part-1] delete "*-inl.h" of newest codex rule move the definition to the declare head file issue: https://gitee.com/openharmony/ark_js_runtime/issues/I512HV Signed-off-by: wengchangcheng Change-Id: Ieeb0ec96281cda51d0bebd6a2e771fc8d4078306 --- ecmascript/base/string_helper.h | 2 +- ecmascript/builtins/builtins_promise.cpp | 2 +- .../builtins/builtins_promise_handler.cpp | 2 +- ecmascript/builtins/builtins_regexp.cpp | 2 +- ecmascript/builtins/builtins_symbol.cpp | 2 +- .../builtins/tests/builtins_symbol_test.cpp | 2 +- ecmascript/dfx/hprof/heap_profiler.cpp | 2 +- ecmascript/dfx/hprof/heap_snapshot.cpp | 2 +- ecmascript/dfx/hprof/tests/hprof_test.cpp | 4 +- ecmascript/dump.cpp | 4 +- ecmascript/ecma_vm.cpp | 4 +- ecmascript/global_env.cpp | 2 +- ecmascript/ic/properties_cache-inl.h | 56 -------------- ecmascript/ic/properties_cache.h | 35 +++++++-- ecmascript/ic/proto_change_details.cpp | 2 +- ecmascript/ic/tests/properties_cache_test.cpp | 2 +- .../ic/tests/proto_change_details_test.cpp | 2 +- ecmascript/interpreter/interpreter-inl.h | 2 +- .../interpreter/interpreter_assembly.cpp | 2 +- ecmascript/interpreter/slow_runtime_stub.cpp | 2 +- ecmascript/jobs/micro_job_queue.cpp | 2 +- ecmascript/js_for_in_iterator.cpp | 2 +- ecmascript/js_hclass.cpp | 2 +- ecmascript/js_primitive_ref.cpp | 2 +- ecmascript/js_promise.h | 2 +- ecmascript/js_thread.cpp | 2 +- ecmascript/jspandafile/js_pandafile.cpp | 2 +- .../jspandafile/js_pandafile_executor.cpp | 2 +- .../jspandafile/js_pandafile_manager.cpp | 2 +- .../jspandafile/panda_file_translator.cpp | 2 +- ecmascript/jspandafile/program_object-inl.h | 30 -------- ecmascript/jspandafile/program_object.h | 6 +- ecmascript/layout_info-inl.h | 2 +- ecmascript/layout_info.cpp | 2 +- ecmascript/layout_info.h | 1 - ecmascript/mem/assert_scope-inl.h | 67 ----------------- ecmascript/mem/assert_scope.h | 38 +++++++++- ecmascript/mem/free_object_list-inl.h | 57 --------------- ecmascript/mem/free_object_list.cpp | 2 +- ecmascript/mem/free_object_list.h | 34 +++++++-- ecmascript/mem/heap.cpp | 2 +- ecmascript/mem/mark_stack-inl.h | 65 ----------------- ecmascript/mem/mark_stack.h | 36 ++++++++- ecmascript/mem/mix_gc.h | 2 +- ecmascript/mem/parallel_work_helper.h | 2 +- ecmascript/mem/stw_young_gc_for_testing-inl.h | 37 ---------- ecmascript/mem/stw_young_gc_for_testing.cpp | 2 +- ecmascript/mem/stw_young_gc_for_testing.h | 13 +++- ecmascript/napi/jsnapi.cpp | 2 +- ecmascript/napi/jsnapi_helper-inl.h | 48 ------------ ecmascript/napi/jsnapi_helper.h | 23 +++++- ecmascript/napi/test/jsnapi_tests.cpp | 2 +- ecmascript/object_factory.cpp | 4 +- ecmascript/symbol_table-inl.h | 73 ------------------- ecmascript/symbol_table.h | 49 +++++++++++-- ecmascript/tagged_queue-inl.h | 48 ------------ ecmascript/tagged_queue.h | 28 ++++++- ecmascript/tests/assert_scope_test.cpp | 2 +- ecmascript/tests/dump_test.cpp | 4 +- ecmascript/tests/js_object_test.cpp | 2 +- ecmascript/tests/js_tagged_queue_test.cpp | 2 +- ecmascript/tests/symbol_table_test.cpp | 2 +- ecmascript/tooling/interface/debugger_api.cpp | 5 +- ecmascript/ts_types/tests/ts_type_test.cpp | 2 +- ecmascript/ts_types/ts_obj_layout_info-inl.h | 68 ----------------- ecmascript/ts_types/ts_obj_layout_info.cpp | 4 +- ecmascript/ts_types/ts_obj_layout_info.h | 56 +++++++++++--- ecmascript/ts_types/ts_type.cpp | 2 +- ecmascript/ts_types/ts_type_table.cpp | 2 +- ecmascript/weak_vector-inl.h | 61 ---------------- ecmascript/weak_vector.cpp | 4 +- ecmascript/weak_vector.h | 40 ++++++++-- 72 files changed, 366 insertions(+), 718 deletions(-) delete mode 100644 ecmascript/ic/properties_cache-inl.h delete mode 100644 ecmascript/jspandafile/program_object-inl.h delete mode 100644 ecmascript/mem/assert_scope-inl.h delete mode 100644 ecmascript/mem/free_object_list-inl.h delete mode 100644 ecmascript/mem/mark_stack-inl.h delete mode 100644 ecmascript/mem/stw_young_gc_for_testing-inl.h delete mode 100644 ecmascript/napi/jsnapi_helper-inl.h delete mode 100644 ecmascript/symbol_table-inl.h delete mode 100644 ecmascript/tagged_queue-inl.h delete mode 100644 ecmascript/ts_types/ts_obj_layout_info-inl.h delete mode 100644 ecmascript/weak_vector-inl.h diff --git a/ecmascript/base/string_helper.h b/ecmascript/base/string_helper.h index 1f6383def4..a4b09ff0d9 100644 --- a/ecmascript/base/string_helper.h +++ b/ecmascript/base/string_helper.h @@ -27,7 +27,7 @@ #include "ecmascript/ecma_string-inl.h" #include "ecmascript/ecma_vm.h" #include "ecmascript/js_thread.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/object_factory.h" #include "libpandafile/file_items.h" #include "unicode/unistr.h" diff --git a/ecmascript/builtins/builtins_promise.cpp b/ecmascript/builtins/builtins_promise.cpp index b98e86a0ce..4032ab6c0f 100644 --- a/ecmascript/builtins/builtins_promise.cpp +++ b/ecmascript/builtins/builtins_promise.cpp @@ -29,7 +29,7 @@ #include "ecmascript/js_tagged_number.h" #include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/js_thread.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/object_factory.h" namespace panda::ecmascript::builtins { diff --git a/ecmascript/builtins/builtins_promise_handler.cpp b/ecmascript/builtins/builtins_promise_handler.cpp index 966e132570..d8fa32ed2b 100644 --- a/ecmascript/builtins/builtins_promise_handler.cpp +++ b/ecmascript/builtins/builtins_promise_handler.cpp @@ -23,7 +23,7 @@ #include "ecmascript/js_handle.h" #include "ecmascript/js_promise.h" #include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" namespace panda::ecmascript::builtins { // es6 25.4.1.3.2 Promise Resolve Functions diff --git a/ecmascript/builtins/builtins_regexp.cpp b/ecmascript/builtins/builtins_regexp.cpp index 93463daeca..c9fa54f448 100644 --- a/ecmascript/builtins/builtins_regexp.cpp +++ b/ecmascript/builtins/builtins_regexp.cpp @@ -26,7 +26,7 @@ #include "ecmascript/js_object-inl.h" #include "ecmascript/js_regexp.h" #include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/mem/c_containers.h" #include "ecmascript/mem/chunk_containers.h" #include "ecmascript/object_factory.h" diff --git a/ecmascript/builtins/builtins_symbol.cpp b/ecmascript/builtins/builtins_symbol.cpp index e8689adc19..bcee39acfa 100644 --- a/ecmascript/builtins/builtins_symbol.cpp +++ b/ecmascript/builtins/builtins_symbol.cpp @@ -21,7 +21,7 @@ #include "ecmascript/js_symbol.h" #include "ecmascript/js_tagged_value.h" #include "ecmascript/object_factory.h" -#include "ecmascript/symbol_table-inl.h" +#include "ecmascript/symbol_table.h" #include "utils/bit_utils.h" namespace panda::ecmascript::builtins { diff --git a/ecmascript/builtins/tests/builtins_symbol_test.cpp b/ecmascript/builtins/tests/builtins_symbol_test.cpp index f763133ef7..1813e7ae24 100644 --- a/ecmascript/builtins/tests/builtins_symbol_test.cpp +++ b/ecmascript/builtins/tests/builtins_symbol_test.cpp @@ -26,7 +26,7 @@ #include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/js_thread.h" #include "ecmascript/object_factory.h" -#include "ecmascript/symbol_table-inl.h" +#include "ecmascript/symbol_table.h" #include "ecmascript/tests/test_helper.h" #include "utils/bit_utils.h" diff --git a/ecmascript/dfx/hprof/heap_profiler.cpp b/ecmascript/dfx/hprof/heap_profiler.cpp index d843d76fe7..46f46a43c2 100644 --- a/ecmascript/dfx/hprof/heap_profiler.cpp +++ b/ecmascript/dfx/hprof/heap_profiler.cpp @@ -22,7 +22,7 @@ #include "ecmascript/dfx/hprof/heap_snapshot.h" #include "ecmascript/ecma_vm.h" #include "ecmascript/js_thread.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/mem/concurrent_sweeper.h" #include "ecmascript/mem/heap-inl.h" diff --git a/ecmascript/dfx/hprof/heap_snapshot.cpp b/ecmascript/dfx/hprof/heap_snapshot.cpp index 3135cc5654..0d9409c3dd 100644 --- a/ecmascript/dfx/hprof/heap_snapshot.cpp +++ b/ecmascript/dfx/hprof/heap_snapshot.cpp @@ -29,7 +29,7 @@ #include "ecmascript/js_symbol.h" #include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/js_thread.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/property_attributes.h" #include "ecmascript/tagged_array.h" #include "ecmascript/tagged_dictionary.h" diff --git a/ecmascript/dfx/hprof/tests/hprof_test.cpp b/ecmascript/dfx/hprof/tests/hprof_test.cpp index ee63502656..f86bac89b1 100644 --- a/ecmascript/dfx/hprof/tests/hprof_test.cpp +++ b/ecmascript/dfx/hprof/tests/hprof_test.cpp @@ -30,7 +30,7 @@ #include "ecmascript/ic/proto_change_details.h" #include "ecmascript/jobs/micro_job_queue.h" #include "ecmascript/jobs/pending_job.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_arguments.h" #include "ecmascript/js_array.h" #include "ecmascript/js_array_iterator.h" @@ -68,7 +68,7 @@ #include "ecmascript/layout_info-inl.h" #include "ecmascript/lexical_env.h" #include "ecmascript/linked_hash_table-inl.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/mem/c_containers.h" #include "ecmascript/mem/machine_code.h" #include "ecmascript/object_factory.h" diff --git a/ecmascript/dump.cpp b/ecmascript/dump.cpp index 2d4835a4fa..9ede88323f 100644 --- a/ecmascript/dump.cpp +++ b/ecmascript/dump.cpp @@ -35,7 +35,7 @@ #include "ecmascript/js_api_stack.h" #include "ecmascript/js_api_stack_iterator.h" #include "ecmascript/jspandafile/class_info_extractor.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_api_tree_map.h" #include "ecmascript/js_api_tree_map_iterator.h" #include "ecmascript/js_api_tree_set.h" @@ -79,7 +79,7 @@ #include "ecmascript/layout_info-inl.h" #include "ecmascript/lexical_env.h" #include "ecmascript/linked_hash_table-inl.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/mem/c_containers.h" #include "ecmascript/mem/machine_code.h" #include "ecmascript/module/js_module_namespace.h" diff --git a/ecmascript/ecma_vm.cpp b/ecmascript/ecma_vm.cpp index e1e4dcc7b3..16a82e4e87 100644 --- a/ecmascript/ecma_vm.cpp +++ b/ecmascript/ecma_vm.cpp @@ -38,7 +38,7 @@ #include "ecmascript/jspandafile/js_pandafile_manager.h" #include "ecmascript/jspandafile/module_data_extractor.h" #include "ecmascript/jspandafile/panda_file_translator.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_arraybuffer.h" #include "ecmascript/js_for_in_iterator.h" #include "ecmascript/js_native_pointer.h" @@ -60,7 +60,7 @@ #include "ecmascript/symbol_table.h" #include "ecmascript/tagged_array-inl.h" #include "ecmascript/tagged_dictionary.h" -#include "ecmascript/tagged_queue-inl.h" +#include "ecmascript/tagged_queue.h" #include "ecmascript/tagged_queue.h" #include "ecmascript/template_map.h" #include "ecmascript/ts_types/ts_loader.h" diff --git a/ecmascript/global_env.cpp b/ecmascript/global_env.cpp index 7621963235..295058f84b 100644 --- a/ecmascript/global_env.cpp +++ b/ecmascript/global_env.cpp @@ -18,7 +18,7 @@ #include "ecmascript/ic/ic_handler.h" #include "ecmascript/ic/proto_change_details.h" #include "ecmascript/jobs/micro_job_queue.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_generator_object.h" #include "ecmascript/js_handle.h" #include "ecmascript/js_promise.h" diff --git a/ecmascript/ic/properties_cache-inl.h b/ecmascript/ic/properties_cache-inl.h deleted file mode 100644 index 9f8b62befa..0000000000 --- a/ecmascript/ic/properties_cache-inl.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_IC_PROPERTIES_CACHE_INL_H -#define ECMASCRIPT_IC_PROPERTIES_CACHE_INL_H - -#include "ecmascript/ic/properties_cache.h" -#include "ecmascript/js_tagged_value-inl.h" - -namespace panda::ecmascript { -int PropertiesCache::Get(JSHClass *jsHclass, JSTaggedValue key) -{ - int hash = Hash(jsHclass, key); - PropertyKey &prop = keys_[hash]; - if ((prop.hclass_ == jsHclass) && (prop.key_ == key)) { - return keys_[hash].results_; - } - return NOT_FOUND; -} - -void PropertiesCache::Set(JSHClass *jsHclass, JSTaggedValue key, int index) -{ - int hash = Hash(jsHclass, key); - PropertyKey &prop = keys_[hash]; - prop.hclass_ = jsHclass; - prop.key_ = key; - keys_[hash].results_ = index; -} - -void PropertiesCache::Clear() -{ - for (auto &key : keys_) { - key.hclass_ = nullptr; - } -} - -int PropertiesCache::Hash(JSHClass *cls, JSTaggedValue key) -{ - uint32_t clsHash = static_cast(reinterpret_cast(cls)) >> 3U; // skip 8bytes - uint32_t keyHash = key.GetKeyHashCode(); - return static_cast((clsHash ^ keyHash) & CACHE_LENGTH_MASK); -} -} // namespace panda::ecmascript -#endif // ECMASCRIPT_IC_PROPERTIES_CACHE_INL_H diff --git a/ecmascript/ic/properties_cache.h b/ecmascript/ic/properties_cache.h index c46676f186..416af405e0 100644 --- a/ecmascript/ic/properties_cache.h +++ b/ecmascript/ic/properties_cache.h @@ -19,16 +19,36 @@ #include #include "ecmascript/js_hclass.h" -#include "ecmascript/js_tagged_value.h" +#include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/ecma_macros.h" namespace panda::ecmascript { class EcmaVM; class PropertiesCache { public: - inline int Get(JSHClass *jsHclass, JSTaggedValue key); - inline void Set(JSHClass *jsHclass, JSTaggedValue key, int index); - inline void Clear(); + inline int Get(JSHClass *jsHclass, JSTaggedValue key) + { + int hash = Hash(jsHclass, key); + PropertyKey &prop = keys_[hash]; + if ((prop.hclass_ == jsHclass) && (prop.key_ == key)) { + return keys_[hash].results_; + } + return NOT_FOUND; + } + inline void Set(JSHClass *jsHclass, JSTaggedValue key, int index) + { + int hash = Hash(jsHclass, key); + PropertyKey &prop = keys_[hash]; + prop.hclass_ = jsHclass; + prop.key_ = key; + keys_[hash].results_ = index; + } + inline void Clear() + { + for (auto &key : keys_) { + key.hclass_ = nullptr; + } + } static const int NOT_FOUND = -1; @@ -49,7 +69,12 @@ private: int results_{NOT_FOUND}; }; - static inline int Hash(JSHClass *cls, JSTaggedValue key); + static inline int Hash(JSHClass *cls, JSTaggedValue key) + { + uint32_t clsHash = static_cast(reinterpret_cast(cls)) >> 3U; // skip 8bytes + uint32_t keyHash = key.GetKeyHashCode(); + return static_cast((clsHash ^ keyHash) & CACHE_LENGTH_MASK); + } static const uint32_t CACHE_LENGTH_BIT = 10; static const uint32_t CACHE_LENGTH = (1U << CACHE_LENGTH_BIT); diff --git a/ecmascript/ic/proto_change_details.cpp b/ecmascript/ic/proto_change_details.cpp index de8a0c5458..adb704647e 100644 --- a/ecmascript/ic/proto_change_details.cpp +++ b/ecmascript/ic/proto_change_details.cpp @@ -14,7 +14,7 @@ */ #include "ecmascript/ic/proto_change_details.h" -#include "ecmascript/weak_vector-inl.h" +#include "ecmascript/weak_vector.h" namespace panda::ecmascript { JSHandle ChangeListener::Add(const JSThread *thread, const JSHandle &array, diff --git a/ecmascript/ic/tests/properties_cache_test.cpp b/ecmascript/ic/tests/properties_cache_test.cpp index 0103da07d4..7e71325411 100644 --- a/ecmascript/ic/tests/properties_cache_test.cpp +++ b/ecmascript/ic/tests/properties_cache_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "ecmascript/ic/properties_cache-inl.h" +#include "ecmascript/ic/properties_cache.h" #include "ecmascript/js_object.h" #include "ecmascript/js_symbol.h" #include "ecmascript/tests/test_helper.h" diff --git a/ecmascript/ic/tests/proto_change_details_test.cpp b/ecmascript/ic/tests/proto_change_details_test.cpp index 1be97aaa12..26e15515f2 100644 --- a/ecmascript/ic/tests/proto_change_details_test.cpp +++ b/ecmascript/ic/tests/proto_change_details_test.cpp @@ -17,7 +17,7 @@ #include "ecmascript/global_env.h" #include "ecmascript/tagged_array.h" #include "ecmascript/tests/test_helper.h" -#include "ecmascript/weak_vector-inl.h" +#include "ecmascript/weak_vector.h" using namespace panda::ecmascript; diff --git a/ecmascript/interpreter/interpreter-inl.h b/ecmascript/interpreter/interpreter-inl.h index e1c058e4d6..471d18a10b 100644 --- a/ecmascript/interpreter/interpreter-inl.h +++ b/ecmascript/interpreter/interpreter-inl.h @@ -29,7 +29,7 @@ #include "ecmascript/interpreter/frame_handler.h" #include "ecmascript/interpreter/slow_runtime_stub.h" #include "ecmascript/jspandafile/literal_data_extractor.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_generator_object.h" #include "ecmascript/js_tagged_value.h" #include "ecmascript/mem/concurrent_marker.h" diff --git a/ecmascript/interpreter/interpreter_assembly.cpp b/ecmascript/interpreter/interpreter_assembly.cpp index aa57fdb5e8..de38797245 100644 --- a/ecmascript/interpreter/interpreter_assembly.cpp +++ b/ecmascript/interpreter/interpreter_assembly.cpp @@ -24,7 +24,7 @@ #include "ecmascript/interpreter/frame_handler.h" #include "ecmascript/interpreter/slow_runtime_stub.h" #include "ecmascript/jspandafile/literal_data_extractor.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_generator_object.h" #include "ecmascript/js_tagged_value.h" #include "ecmascript/mem/concurrent_marker.h" diff --git a/ecmascript/interpreter/slow_runtime_stub.cpp b/ecmascript/interpreter/slow_runtime_stub.cpp index 7ddb7f6d8b..9c9206e38a 100644 --- a/ecmascript/interpreter/slow_runtime_stub.cpp +++ b/ecmascript/interpreter/slow_runtime_stub.cpp @@ -24,7 +24,7 @@ #include "ecmascript/interpreter/frame_handler.h" #include "ecmascript/interpreter/interpreter-inl.h" #include "ecmascript/interpreter/slow_runtime_helper.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/jspandafile/scope_info_extractor.h" #include "ecmascript/js_arguments.h" #include "ecmascript/js_array.h" diff --git a/ecmascript/jobs/micro_job_queue.cpp b/ecmascript/jobs/micro_job_queue.cpp index 87605df736..14c046c399 100644 --- a/ecmascript/jobs/micro_job_queue.cpp +++ b/ecmascript/jobs/micro_job_queue.cpp @@ -22,7 +22,7 @@ #include "ecmascript/js_tagged_value.h" #include "ecmascript/js_thread.h" #include "ecmascript/object_factory.h" -#include "ecmascript/tagged_queue-inl.h" +#include "ecmascript/tagged_queue.h" #include "ecmascript/tagged_queue.h" #include "utils/expected.h" diff --git a/ecmascript/js_for_in_iterator.cpp b/ecmascript/js_for_in_iterator.cpp index ce98a5ea93..676aee425b 100644 --- a/ecmascript/js_for_in_iterator.cpp +++ b/ecmascript/js_for_in_iterator.cpp @@ -23,7 +23,7 @@ #include "ecmascript/object_factory.h" #include "ecmascript/tagged_array-inl.h" #include "ecmascript/tagged_dictionary.h" -#include "ecmascript/tagged_queue-inl.h" +#include "ecmascript/tagged_queue.h" #include "ecmascript/tagged_queue.h" namespace panda::ecmascript { diff --git a/ecmascript/js_hclass.cpp b/ecmascript/js_hclass.cpp index 41bf80a1f2..ad6e4e559e 100644 --- a/ecmascript/js_hclass.cpp +++ b/ecmascript/js_hclass.cpp @@ -24,7 +24,7 @@ #include "ecmascript/js_symbol.h" #include "ecmascript/mem/c_containers.h" #include "ecmascript/tagged_array-inl.h" -#include "ecmascript/weak_vector-inl.h" +#include "ecmascript/weak_vector.h" namespace panda::ecmascript { JSHandle TransitionsDictionary::PutIfAbsent(const JSThread *thread, diff --git a/ecmascript/js_primitive_ref.cpp b/ecmascript/js_primitive_ref.cpp index acbb15fb96..30d037e84f 100644 --- a/ecmascript/js_primitive_ref.cpp +++ b/ecmascript/js_primitive_ref.cpp @@ -17,7 +17,7 @@ #include "ecmascript/ecma_string-inl.h" #include "ecmascript/ecma_vm.h" #include "ecmascript/global_env.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/object_factory.h" namespace panda::ecmascript { diff --git a/ecmascript/js_promise.h b/ecmascript/js_promise.h index de24f4749d..36000952d0 100644 --- a/ecmascript/js_promise.h +++ b/ecmascript/js_promise.h @@ -22,7 +22,7 @@ #include "ecmascript/js_tagged_value.h" #include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/tagged_queue.h" -#include "ecmascript/tagged_queue-inl.h" +#include "ecmascript/tagged_queue.h" namespace panda::ecmascript { enum class PromiseState : uint8_t { PENDING = 0, FULFILLED, REJECTED }; diff --git a/ecmascript/js_thread.cpp b/ecmascript/js_thread.cpp index 03ccc3b2a5..57f4bb859e 100644 --- a/ecmascript/js_thread.cpp +++ b/ecmascript/js_thread.cpp @@ -15,7 +15,7 @@ #include "ecmascript/js_thread.h" #include "ecmascript/compiler/llvm/llvm_stackmap_parser.h" #include "ecmascript/global_env_constants-inl.h" -#include "ecmascript/ic/properties_cache-inl.h" +#include "ecmascript/ic/properties_cache.h" #include "ecmascript/internal_call_params.h" #include "ecmascript/interpreter/interpreter-inl.h" #include "ecmascript/mem/machine_code.h" diff --git a/ecmascript/jspandafile/js_pandafile.cpp b/ecmascript/jspandafile/js_pandafile.cpp index 6bf4e9611f..92b067dc2d 100644 --- a/ecmascript/jspandafile/js_pandafile.cpp +++ b/ecmascript/jspandafile/js_pandafile.cpp @@ -16,7 +16,7 @@ #include "ecmascript/jspandafile/js_pandafile.h" #include "ecmascript/jspandafile/js_pandafile_manager.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" namespace panda::ecmascript { JSPandaFile::JSPandaFile(const panda_file::File *pf, const CString &descriptor) : pf_(pf), desc_(descriptor) diff --git a/ecmascript/jspandafile/js_pandafile_executor.cpp b/ecmascript/jspandafile/js_pandafile_executor.cpp index 4a03c72e57..6855e501c7 100644 --- a/ecmascript/jspandafile/js_pandafile_executor.cpp +++ b/ecmascript/jspandafile/js_pandafile_executor.cpp @@ -17,7 +17,7 @@ #include "ecmascript/ecma_vm.h" #include "ecmascript/internal_call_params.h" #include "ecmascript/jspandafile/js_pandafile_manager.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/module/js_module_manager.h" namespace panda::ecmascript { diff --git a/ecmascript/jspandafile/js_pandafile_manager.cpp b/ecmascript/jspandafile/js_pandafile_manager.cpp index be99be6480..4fc4876344 100644 --- a/ecmascript/jspandafile/js_pandafile_manager.cpp +++ b/ecmascript/jspandafile/js_pandafile_manager.cpp @@ -15,7 +15,7 @@ #include "ecmascript/jspandafile/js_pandafile_manager.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" namespace panda::ecmascript { static const size_t MALLOC_SIZE_LIMIT = 2147483648; // Max internal memory used by the VM declared in options diff --git a/ecmascript/jspandafile/panda_file_translator.cpp b/ecmascript/jspandafile/panda_file_translator.cpp index a1bcb6a409..31f3b089fc 100644 --- a/ecmascript/jspandafile/panda_file_translator.cpp +++ b/ecmascript/jspandafile/panda_file_translator.cpp @@ -20,7 +20,7 @@ #include "ecmascript/jspandafile/class_info_extractor.h" #include "ecmascript/jspandafile/literal_data_extractor.h" #include "ecmascript/jspandafile/js_pandafile_manager.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_array.h" #include "ecmascript/js_function.h" #include "ecmascript/js_thread.h" diff --git a/ecmascript/jspandafile/program_object-inl.h b/ecmascript/jspandafile/program_object-inl.h deleted file mode 100644 index ed5d0bd87c..0000000000 --- a/ecmascript/jspandafile/program_object-inl.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_JSPANDAFILE_PROGRAM_OBJECT_INL_H -#define ECMASCRIPT_JSPANDAFILE_PROGRAM_OBJECT_INL_H - -#include "program_object.h" -#include "ecmascript/mem/native_area_allocator.h" - -namespace panda { -namespace ecmascript { -JSTaggedValue ConstantPool::GetObjectFromCache(uint32_t index) const -{ - return Get(index); -} -} // namespace ecmascript -} // namespace panda -#endif // ECMASCRIPT_JSPANDAFILE_PROGRAM_OBJECT_INL_H \ No newline at end of file diff --git a/ecmascript/jspandafile/program_object.h b/ecmascript/jspandafile/program_object.h index afb875e219..4b8a79dc6a 100644 --- a/ecmascript/jspandafile/program_object.h +++ b/ecmascript/jspandafile/program_object.h @@ -43,7 +43,11 @@ public: return static_cast(object); } - inline JSTaggedValue GetObjectFromCache(uint32_t index) const; + inline JSTaggedValue GetObjectFromCache(uint32_t index) const + { + return Get(index); + } + DECL_DUMP() }; } // namespace ecmascript diff --git a/ecmascript/layout_info-inl.h b/ecmascript/layout_info-inl.h index 065eda9da5..ffb1416f28 100644 --- a/ecmascript/layout_info-inl.h +++ b/ecmascript/layout_info-inl.h @@ -18,7 +18,7 @@ #include "ecmascript/layout_info.h" #include "ecmascript/tagged_array-inl.h" -#include "ecmascript/ic/properties_cache-inl.h" +#include "ecmascript/ic/properties_cache.h" namespace panda::ecmascript { inline int LayoutInfo::GetPropertiesCapacity() const diff --git a/ecmascript/layout_info.cpp b/ecmascript/layout_info.cpp index 1617d2a01b..49a951caee 100644 --- a/ecmascript/layout_info.cpp +++ b/ecmascript/layout_info.cpp @@ -16,7 +16,7 @@ #include "ecmascript/layout_info-inl.h" #include "ecmascript/ecma_string.h" #include "ecmascript/js_symbol.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" namespace panda::ecmascript { void LayoutInfo::AddKey(const JSThread *thread, [[maybe_unused]] int index, const JSTaggedValue &key, diff --git a/ecmascript/layout_info.h b/ecmascript/layout_info.h index 5fdb17b7b4..8696cf39d5 100644 --- a/ecmascript/layout_info.h +++ b/ecmascript/layout_info.h @@ -77,7 +77,6 @@ public: } int FindElementWithCache(JSThread *thread, JSHClass *cls, JSTaggedValue key, int propertiesNumber); - int FindElement(JSTaggedValue key, int propertiesNumber); int BinarySearch(JSTaggedValue key, int propertiesNumber); void GetAllKeys(const JSThread *thread, int end, int offset, TaggedArray *keyArray); void GetAllKeys(const JSThread *thread, int end, std::vector &keyVector); diff --git a/ecmascript/mem/assert_scope-inl.h b/ecmascript/mem/assert_scope-inl.h deleted file mode 100644 index f3f3beef77..0000000000 --- a/ecmascript/mem/assert_scope-inl.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_MEM_ASSERT_SCOPE_INL_H -#define ECMASCRIPT_MEM_ASSERT_SCOPE_INL_H - -#include "assert_scope.h" - -namespace panda::ecmascript { -// Thread-local storage for assert data. Default all asserts to "allow". -// NOLINTNEXTLINE(hicpp-signed-bitwise) -static thread_local size_t currentAssertData(~0); - -template -AssertScopeT::AssertScopeT() : oldData_(currentAssertData) -{ - switch (type) { - case AssertType::GARBAGE_COLLECTION_ASSERT: - currentAssertData = AssertGarbageCollectBit::Update(oldData_.value(), isAllow); - break; - case AssertType::HEAP_ALLOC_ASSERT: - currentAssertData = AssertHeapAllocBit::Update(oldData_.value(), isAllow); - break; - default: - break; - } -} - -template -AssertScopeT::~AssertScopeT() -{ - if (!oldData_.has_value()) { - return; - } - - currentAssertData = oldData_.value(); - oldData_.reset(); -} - -// static -template -bool AssertScopeT::IsAllowed() -{ - switch (type) { - case AssertType::GARBAGE_COLLECTION_ASSERT: - return AssertGarbageCollectBit::Decode(currentAssertData); - case AssertType::HEAP_ALLOC_ASSERT: - return AssertHeapAllocBit::Decode(currentAssertData); - default: - return true; - } -} -} // namespace panda::ecmascript - -#endif // ECMASCRIPT_MEM_ASSERT_SCOPE_INL_H \ No newline at end of file diff --git a/ecmascript/mem/assert_scope.h b/ecmascript/mem/assert_scope.h index d7758369de..90b7983796 100644 --- a/ecmascript/mem/assert_scope.h +++ b/ecmascript/mem/assert_scope.h @@ -22,6 +22,8 @@ #include "utils/bit_field.h" namespace panda::ecmascript { +static thread_local size_t currentAssertData(~0); + using AssertGarbageCollectBit = panda::BitField; using AssertHeapAllocBit = AssertGarbageCollectBit::NextFlag; @@ -45,11 +47,41 @@ public: template class AssertScopeT { public: - AssertScopeT(); + AssertScopeT() : oldData_(currentAssertData) + { + switch (type) { + case AssertType::GARBAGE_COLLECTION_ASSERT: + currentAssertData = AssertGarbageCollectBit::Update(oldData_.value(), isAllow); + break; + case AssertType::HEAP_ALLOC_ASSERT: + currentAssertData = AssertHeapAllocBit::Update(oldData_.value(), isAllow); + break; + default: + break; + } + } - ~AssertScopeT(); + ~AssertScopeT() + { + if (!oldData_.has_value()) { + return; + } - static bool IsAllowed(); + currentAssertData = oldData_.value(); + oldData_.reset(); + } + + static bool IsAllowed() + { + switch (type) { + case AssertType::GARBAGE_COLLECTION_ASSERT: + return AssertGarbageCollectBit::Decode(currentAssertData); + case AssertType::HEAP_ALLOC_ASSERT: + return AssertHeapAllocBit::Decode(currentAssertData); + default: + return true; + } + } NO_COPY_SEMANTIC(AssertScopeT); DEFAULT_NOEXCEPT_MOVE_SEMANTIC(AssertScopeT); diff --git a/ecmascript/mem/free_object_list-inl.h b/ecmascript/mem/free_object_list-inl.h deleted file mode 100644 index ba1a8e07cb..0000000000 --- a/ecmascript/mem/free_object_list-inl.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_MEM_FREE_OBJECT_LIST_INL_H -#define ECMASCRIPT_MEM_FREE_OBJECT_LIST_INL_H - -#include "ecmascript/mem/free_object_list.h" - -#include - -namespace panda::ecmascript { -SetType FreeObjectList::SelectSetType(size_t size) const -{ - if (size < SMALL_SET_MAX_SIZE) { - if (UNLIKELY(size < MIN_SIZE)) { - return FreeObjectSet::INVALID_SET_TYPE; - } - return (size >> INTERVAL_OFFSET) - smallSetOffsetIndex; - } - if (size < LARGE_SET_MAX_SIZE) { - return MAX_BIT_OF_SIZET - __builtin_clzl(size) + LOG2_OFFSET; - } - if (size >= HUGE_SET_MAX_SIZE) { - return NUMBER_OF_LAST_HUGE; - } - - return NUMBER_OF_LAST_LARGE; -} - -void FreeObjectList::SetNoneEmptyBit(SetType type) -{ - noneEmptySetBitMap_ |= 1ULL << static_cast(type); -} - -void FreeObjectList::ClearNoneEmptyBit(SetType type) -{ - noneEmptySetBitMap_ &= ~(1ULL << static_cast(type)); -} - -inline size_t FreeObjectList::CalcNextNoneEmptyIndex(SetType start) -{ - return __builtin_ffsll(noneEmptySetBitMap_ >> static_cast(start)) + start - 1; -} -} // namespace panda::ecmascript -#endif // ECMASCRIPT_MEM_FREE_OBJECT_LIST_INL_H diff --git a/ecmascript/mem/free_object_list.cpp b/ecmascript/mem/free_object_list.cpp index 34d5fb2fd7..a4b2c4fbb5 100644 --- a/ecmascript/mem/free_object_list.cpp +++ b/ecmascript/mem/free_object_list.cpp @@ -17,7 +17,7 @@ #include "ecmascript/free_object.h" #include "ecmascript/mem/free_object_set.h" -#include "ecmascript/mem/free_object_list-inl.h" +#include "ecmascript/mem/free_object_list.h" #include "ecmascript/mem/mem.h" namespace panda::ecmascript { diff --git a/ecmascript/mem/free_object_list.h b/ecmascript/mem/free_object_list.h index 90d909f617..a0c8d3b42a 100644 --- a/ecmascript/mem/free_object_list.h +++ b/ecmascript/mem/free_object_list.h @@ -89,11 +89,35 @@ private: static constexpr size_t MAX_BIT_OF_SIZET = sizeof(size_t) << INTERVAL_OFFSET; const int smallSetOffsetIndex = 2; - inline SetType SelectSetType(size_t size) const; - - inline void SetNoneEmptyBit(SetType type); - inline void ClearNoneEmptyBit(SetType type); - inline size_t CalcNextNoneEmptyIndex(SetType start); + inline SetType SelectSetType(size_t size) const + { + if (size < SMALL_SET_MAX_SIZE) { + if (UNLIKELY(size < MIN_SIZE)) { + return FreeObjectSet::INVALID_SET_TYPE; + } + return (size >> INTERVAL_OFFSET) - smallSetOffsetIndex; + } + if (size < LARGE_SET_MAX_SIZE) { + return MAX_BIT_OF_SIZET - __builtin_clzl(size) + LOG2_OFFSET; + } + if (size >= HUGE_SET_MAX_SIZE) { + return NUMBER_OF_LAST_HUGE; + } + + return NUMBER_OF_LAST_LARGE; + } + inline void SetNoneEmptyBit(SetType type) + { + noneEmptySetBitMap_ |= 1ULL << static_cast(type); + } + inline void ClearNoneEmptyBit(SetType type) + { + noneEmptySetBitMap_ &= ~(1ULL << static_cast(type)); + } + inline size_t CalcNextNoneEmptyIndex(SetType start) + { + return __builtin_ffsll(noneEmptySetBitMap_ >> static_cast(start)) + start - 1; + } size_t available_ = 0; size_t wasted_ = 0; diff --git a/ecmascript/mem/heap.cpp b/ecmascript/mem/heap.cpp index 974140464e..3ec3f347fd 100644 --- a/ecmascript/mem/heap.cpp +++ b/ecmascript/mem/heap.cpp @@ -24,7 +24,7 @@ #include "ecmascript/dfx/cpu_profiler/cpu_profiler.h" #endif #include "ecmascript/ecma_vm.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/mem/concurrent_marker.h" #include "ecmascript/mem/concurrent_sweeper.h" #include "ecmascript/mem/full_gc.h" diff --git a/ecmascript/mem/mark_stack-inl.h b/ecmascript/mem/mark_stack-inl.h deleted file mode 100644 index 005791538f..0000000000 --- a/ecmascript/mem/mark_stack-inl.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_MEM_MARK_STACK_INL_H -#define ECMASCRIPT_MEM_MARK_STACK_INL_H - -#include "ecmascript/mem/mark_stack.h" - -#include "ecmascript/mem/native_area_allocator.h" - -namespace panda::ecmascript { -template -void ContinuousStack::BeginMarking(Heap *heap, ContinuousStack *other) -{ - heap_ = heap; - currentArea_ = other->currentArea_; - if (currentArea_ == nullptr) { - currentArea_ = NativeAreaAllocator::AllocateSpace(DEFAULT_MARK_STACK_SIZE); - } - ResetBegin(currentArea_->GetBegin(), currentArea_->GetEnd()); -} - -template -void ContinuousStack::FinishMarking(ContinuousStack *other) -{ - other->currentArea_ = currentArea_; - - while (!unusedList_.IsEmpty()) { - Area *node = unusedList_.PopBack(); - NativeAreaAllocator::FreeSpace(node); - } -} - -template -void ContinuousStack::Extend() -{ - auto area = NativeAreaAllocator::AllocateSpace(DEFAULT_MARK_STACK_SIZE); - areaList_.AddNode(currentArea_); - currentArea_ = area; - ResetBegin(currentArea_->GetBegin(), currentArea_->GetEnd()); -} - -template -void ContinuousStack::Destroy() -{ - if (currentArea_ != nullptr) { - NativeAreaAllocator::FreeSpace(currentArea_); - currentArea_ = nullptr; - } -} -} // namespace panda::ecmascript - -#endif // ECMASCRIPT_MEM_MARK_STACK_INL_H diff --git a/ecmascript/mem/mark_stack.h b/ecmascript/mem/mark_stack.h index 6a2935b261..f790dd1b50 100644 --- a/ecmascript/mem/mark_stack.h +++ b/ecmascript/mem/mark_stack.h @@ -102,8 +102,24 @@ public: NO_COPY_SEMANTIC(ContinuousStack); NO_MOVE_SEMANTIC(ContinuousStack); - inline void BeginMarking(Heap *heap, ContinuousStack *other); - inline void FinishMarking(ContinuousStack *other); + inline void BeginMarking(Heap *heap, ContinuousStack *other) + { + heap_ = heap; + currentArea_ = other->currentArea_; + if (currentArea_ == nullptr) { + currentArea_ = NativeAreaAllocator::AllocateSpace(DEFAULT_MARK_STACK_SIZE); + } + ResetBegin(currentArea_->GetBegin(), currentArea_->GetEnd()); + } + inline void FinishMarking(ContinuousStack *other) + { + other->currentArea_ = currentArea_; + + while (!unusedList_.IsEmpty()) { + Area *node = unusedList_.PopBack(); + NativeAreaAllocator::FreeSpace(node); + } + } T *PopBack() { @@ -128,10 +144,22 @@ public: PushBackUnchecked(ToUintPtr(obj)); } - inline void Destroy(); + inline void Destroy() + { + if (currentArea_ != nullptr) { + NativeAreaAllocator::FreeSpace(currentArea_); + currentArea_ = nullptr; + } + } private: - inline void Extend(); + inline void Extend() + { + auto area = NativeAreaAllocator::AllocateSpace(DEFAULT_MARK_STACK_SIZE); + areaList_.AddNode(currentArea_); + currentArea_ = area; + ResetBegin(currentArea_->GetBegin(), currentArea_->GetEnd()); + } Heap *heap_{nullptr}; Area *currentArea_{nullptr}; diff --git a/ecmascript/mem/mix_gc.h b/ecmascript/mem/mix_gc.h index a68579866e..e4e162ad5d 100644 --- a/ecmascript/mem/mix_gc.h +++ b/ecmascript/mem/mix_gc.h @@ -19,7 +19,7 @@ #include "ecmascript/mem/mem.h" #include "ecmascript/mem/heap.h" #include "ecmascript/mem/allocator.h" -#include "ecmascript/mem/mark_stack-inl.h" +#include "ecmascript/mem/mark_stack.h" #include "ecmascript/mem/mark_word.h" #include "ecmascript/mem/parallel_work_helper.h" #include "ecmascript/mem/slots.h" diff --git a/ecmascript/mem/parallel_work_helper.h b/ecmascript/mem/parallel_work_helper.h index b0da45be28..bbf038289c 100644 --- a/ecmascript/mem/parallel_work_helper.h +++ b/ecmascript/mem/parallel_work_helper.h @@ -16,7 +16,7 @@ #ifndef ECMASCRIPT_MEM_PARALLEL_WORK_HELPER_H #define ECMASCRIPT_MEM_PARALLEL_WORK_HELPER_H -#include "ecmascript/mem/mark_stack-inl.h" +#include "ecmascript/mem/mark_stack.h" #include "ecmascript/mem/slots.h" #include "ecmascript/taskpool/taskpool.h" diff --git a/ecmascript/mem/stw_young_gc_for_testing-inl.h b/ecmascript/mem/stw_young_gc_for_testing-inl.h deleted file mode 100644 index 6abdd982f2..0000000000 --- a/ecmascript/mem/stw_young_gc_for_testing-inl.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_MEM_STW_YOUNG_GC_FOR_TESTING_INL_H -#define ECMASCRIPT_MEM_STW_YOUNG_GC_FOR_TESTING_INL_H - -#include "ecmascript/mem/stw_young_gc_for_testing.h" - -#include "ecmascript/js_hclass-inl.h" -#include "ecmascript/mem/parallel_work_helper.h" - -namespace panda::ecmascript { -void STWYoungGC::UpdatePromotedSlot(TaggedObject *object, ObjectSlot slot) -{ -#ifndef NDEBUG - JSTaggedValue value(slot.GetTaggedType()); - ASSERT(value.IsHeapObject()); -#endif - Region *objectRegion = Region::ObjectAddressToRange(object); - ASSERT(!objectRegion->InYoungGeneration()); - objectRegion->InsertOldToNewRememberedSet(slot.SlotAddress()); -} -} // namespace panda::ecmascript - -#endif // ECMASCRIPT_MEM_STW_YOUNG_GC_FOR_TESTING_INL_H diff --git a/ecmascript/mem/stw_young_gc_for_testing.cpp b/ecmascript/mem/stw_young_gc_for_testing.cpp index 6d8e314f58..f55be27997 100644 --- a/ecmascript/mem/stw_young_gc_for_testing.cpp +++ b/ecmascript/mem/stw_young_gc_for_testing.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "ecmascript/mem/stw_young_gc_for_testing-inl.h" +#include "ecmascript/mem/stw_young_gc_for_testing.h" #include "ecmascript/ecma_vm.h" #include "ecmascript/mem/clock_scope.h" diff --git a/ecmascript/mem/stw_young_gc_for_testing.h b/ecmascript/mem/stw_young_gc_for_testing.h index 0437722dea..3fe314d2f7 100644 --- a/ecmascript/mem/stw_young_gc_for_testing.h +++ b/ecmascript/mem/stw_young_gc_for_testing.h @@ -20,7 +20,7 @@ #include "ecmascript/mem/mem.h" #include "ecmascript/mem/heap.h" #include "ecmascript/mem/allocator.h" -#include "ecmascript/mem/mark_stack-inl.h" +#include "ecmascript/mem/mark_stack.h" #include "ecmascript/mem/mark_word.h" #include "ecmascript/mem/slots.h" #include "ecmascript/mem/object_xray.h" @@ -59,7 +59,16 @@ private: void SweepPhases(); void FinishPhase(); - inline void UpdatePromotedSlot(TaggedObject *object, ObjectSlot slot); + inline void UpdatePromotedSlot(TaggedObject *object, ObjectSlot slot) + { +#ifndef NDEBUG + JSTaggedValue value(slot.GetTaggedType()); + ASSERT(value.IsHeapObject()); +#endif + Region *objectRegion = Region::ObjectAddressToRange(object); + ASSERT(!objectRegion->InYoungGeneration()); + objectRegion->InsertOldToNewRememberedSet(slot.SlotAddress()); + } Heap *heap_; size_t promotedSize_{0}; diff --git a/ecmascript/napi/jsnapi.cpp b/ecmascript/napi/jsnapi.cpp index eb5531b2e7..1a1b692a13 100644 --- a/ecmascript/napi/jsnapi.cpp +++ b/ecmascript/napi/jsnapi.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "jsnapi_helper-inl.h" +#include "jsnapi_helper.h" #include #include diff --git a/ecmascript/napi/jsnapi_helper-inl.h b/ecmascript/napi/jsnapi_helper-inl.h deleted file mode 100644 index 1429ddadcb..0000000000 --- a/ecmascript/napi/jsnapi_helper-inl.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_NAPI_JSNAPI_HELPER_INL_H -#define ECMASCRIPT_NAPI_JSNAPI_HELPER_INL_H - -#include "ecmascript/js_tagged_value.h" -#include "jsnapi_helper.h" -#include "libpandabase/macros.h" - -namespace panda { -template -Local JSNApiHelper::ToLocal(ecmascript::JSHandle from) -{ - return Local(from.GetAddress()); -} - -ecmascript::JSTaggedValue JSNApiHelper::ToJSTaggedValue(JSValueRef *from) -{ - ASSERT(from != nullptr); - return *reinterpret_cast(from); -} - -ecmascript::JSHandle JSNApiHelper::ToJSHandle(Local from) -{ - ASSERT(!from.IsEmpty()); - return ecmascript::JSHandle(reinterpret_cast(*from)); -} - -ecmascript::JSHandle JSNApiHelper::ToJSHandle(JSValueRef *from) -{ - ASSERT(from != nullptr); - return ecmascript::JSHandle(reinterpret_cast(from)); -} -} // namespace panda -#endif // ECMASCRIPT_NAPI_JSNAPI_HELPER_INL_H \ No newline at end of file diff --git a/ecmascript/napi/jsnapi_helper.h b/ecmascript/napi/jsnapi_helper.h index fadab07d12..3fd4191412 100644 --- a/ecmascript/napi/jsnapi_helper.h +++ b/ecmascript/napi/jsnapi_helper.h @@ -64,13 +64,28 @@ namespace panda { class JSNApiHelper { public: template - static inline Local ToLocal(ecmascript::JSHandle from); + static inline Local ToLocal(ecmascript::JSHandle from) + { + return Local(from.GetAddress()); + } - static inline ecmascript::JSTaggedValue ToJSTaggedValue(JSValueRef *from); + static inline ecmascript::JSTaggedValue ToJSTaggedValue(JSValueRef *from) + { + ASSERT(from != nullptr); + return *reinterpret_cast(from); + } - static inline ecmascript::JSHandle ToJSHandle(Local from); + static inline ecmascript::JSHandle ToJSHandle(Local from) + { + ASSERT(!from.IsEmpty()); + return ecmascript::JSHandle(reinterpret_cast(*from)); + } - static inline ecmascript::JSHandle ToJSHandle(JSValueRef *from); + static inline ecmascript::JSHandle ToJSHandle(JSValueRef *from) + { + ASSERT(from != nullptr); + return ecmascript::JSHandle(reinterpret_cast(from)); + } }; class Callback { diff --git a/ecmascript/napi/test/jsnapi_tests.cpp b/ecmascript/napi/test/jsnapi_tests.cpp index cdf08a063b..aaecae7a0d 100644 --- a/ecmascript/napi/test/jsnapi_tests.cpp +++ b/ecmascript/napi/test/jsnapi_tests.cpp @@ -21,7 +21,7 @@ #include "ecmascript/global_env.h" #include "ecmascript/js_thread.h" #include "ecmascript/napi/include/jsnapi.h" -#include "ecmascript/napi/jsnapi_helper-inl.h" +#include "ecmascript/napi/jsnapi_helper.h" #include "ecmascript/object_factory.h" using namespace panda; diff --git a/ecmascript/object_factory.cpp b/ecmascript/object_factory.cpp index 22e894b14f..8dfc3f6c2d 100644 --- a/ecmascript/object_factory.cpp +++ b/ecmascript/object_factory.cpp @@ -85,10 +85,10 @@ #include "ecmascript/module/js_module_source_text.h" #include "ecmascript/record.h" #include "ecmascript/sharedMemoryManaged/sharedmemorymanager.h" -#include "ecmascript/symbol_table-inl.h" +#include "ecmascript/symbol_table.h" #include "ecmascript/tagged_tree-inl.h" #include "ecmascript/template_map.h" -#include "ecmascript/ts_types/ts_obj_layout_info-inl.h" +#include "ecmascript/ts_types/ts_obj_layout_info.h" #include "ecmascript/ts_types/ts_type.h" #include "ecmascript/ts_types/ts_type_table.h" diff --git a/ecmascript/symbol_table-inl.h b/ecmascript/symbol_table-inl.h deleted file mode 100644 index 9af388e851..0000000000 --- a/ecmascript/symbol_table-inl.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_SYMBOL_TABLE_INL_H -#define ECMASCRIPT_SYMBOL_TABLE_INL_H - -#include "symbol_table.h" -#include "js_symbol.h" -#include "tagged_hash_table-inl.h" -#include "libpandabase/utils/hash.h" - -namespace panda::ecmascript { -uint32_t SymbolTable::Hash(const JSTaggedValue &obj) -{ - if (obj.IsHeapObject()) { - if (obj.IsString()) { - auto *nameString = static_cast(obj.GetTaggedObject()); - return nameString->GetHashcode(); - } - return JSSymbol::ComputeHash(); - } - UNREACHABLE(); -} - -bool SymbolTable::IsMatch(const JSTaggedValue &name, const JSTaggedValue &other) -{ - if (name.IsHole() || name.IsUndefined()) { - return false; - } - - auto *nameString = static_cast(name.GetTaggedObject()); - auto *otherString = static_cast(other.GetTaggedObject()); - return EcmaString::StringsAreEqual(nameString, otherString); -} - -bool SymbolTable::ContainsKey(const JSTaggedValue &key) -{ - int entry = FindEntry(key); - return entry != -1; -} - -JSTaggedValue SymbolTable::GetSymbol(const JSTaggedValue &key) -{ - int entry = FindEntry(key); - ASSERT(entry != -1); - return GetValue(entry); -} - -JSTaggedValue SymbolTable::FindSymbol(const JSTaggedValue &value) -{ - JSSymbol *symbol = JSSymbol::Cast(value.GetTaggedObject()); - JSTaggedValue des = symbol->GetDescription(); - if (!des.IsUndefined()) { - if (ContainsKey(des)) { - return des; - } - } - return JSTaggedValue::Undefined(); -} -} // namespace panda::ecmascript -#endif // ECMASCRIPT_SYMBOL_TABLE_INL_H \ No newline at end of file diff --git a/ecmascript/symbol_table.h b/ecmascript/symbol_table.h index 413f994f6c..5e58d62fc3 100644 --- a/ecmascript/symbol_table.h +++ b/ecmascript/symbol_table.h @@ -18,6 +18,7 @@ #include "ecmascript/tagged_hash_table.h" #include "ecmascript/ecma_string.h" +#include "ecmascript/js_symbol.h" #include "ecmascript/js_thread.h" namespace panda::ecmascript { @@ -44,8 +45,27 @@ public: { return ENTRY_SIZE; } - static inline bool IsMatch(const JSTaggedValue &name, const JSTaggedValue &other); - static inline uint32_t Hash(const JSTaggedValue &obj); + static inline bool IsMatch(const JSTaggedValue &name, const JSTaggedValue &other) + { + if (name.IsHole() || name.IsUndefined()) { + return false; + } + + auto *nameString = static_cast(name.GetTaggedObject()); + auto *otherString = static_cast(other.GetTaggedObject()); + return EcmaString::StringsAreEqual(nameString, otherString); + } + static inline uint32_t Hash(const JSTaggedValue &obj) + { + if (obj.IsHeapObject()) { + if (obj.IsString()) { + auto *nameString = static_cast(obj.GetTaggedObject()); + return nameString->GetHashcode(); + } + return JSSymbol::ComputeHash(); + } + UNREACHABLE(); + } static const int DEFAULT_ELEMENTS_NUMBER = 64; static JSHandle Create(JSThread *thread, int numberOfElements = DEFAULT_ELEMENTS_NUMBER) @@ -53,11 +73,30 @@ public: return HashTable::Create(thread, numberOfElements); } - inline bool ContainsKey(const JSTaggedValue &key); + inline bool ContainsKey(const JSTaggedValue &key) + { + int entry = FindEntry(key); + return entry != -1; + } - inline JSTaggedValue GetSymbol(const JSTaggedValue &key); + inline JSTaggedValue GetSymbol(const JSTaggedValue &key) + { + int entry = FindEntry(key); + ASSERT(entry != -1); + return GetValue(entry); + } - inline JSTaggedValue FindSymbol(const JSTaggedValue &value); + inline JSTaggedValue FindSymbol(const JSTaggedValue &value) + { + JSSymbol *symbol = JSSymbol::Cast(value.GetTaggedObject()); + JSTaggedValue des = symbol->GetDescription(); + if (!des.IsUndefined()) { + if (ContainsKey(des)) { + return des; + } + } + return JSTaggedValue::Undefined(); + } static constexpr int ENTRY_KEY_INDEX = 0; static constexpr int ENTRY_VALUE_INDEX = 1; static constexpr int ENTRY_SIZE = 2; diff --git a/ecmascript/tagged_queue-inl.h b/ecmascript/tagged_queue-inl.h deleted file mode 100644 index 30f5b582ca..0000000000 --- a/ecmascript/tagged_queue-inl.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_TAGGED_QUEUE_INL_H -#define ECMASCRIPT_TAGGED_QUEUE_INL_H - -#include "ecmascript/tagged_queue.h" - -namespace panda::ecmascript { -inline TaggedQueue *TaggedQueue::Create(JSThread *thread, uint32_t capacity, JSTaggedValue initVal) -{ - uint32_t length = QueueToArrayIndex(capacity); - - auto queue = TaggedQueue::Cast(*thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length, initVal)); - queue->SetStart(thread, JSTaggedValue(0)); // equal to 0 when add 1. - queue->SetEnd(thread, JSTaggedValue(0)); - queue->SetCapacity(thread, JSTaggedValue(capacity)); - return queue; -} - -inline JSTaggedValue TaggedQueue::Pop(JSThread *thread) -{ - if (Empty()) { - return JSTaggedValue::Hole(); - } - - uint32_t start = GetStart().GetArrayLength(); - JSTaggedValue value = Get(start); - - uint32_t capacity = GetCapacity().GetArrayLength(); - ASSERT(capacity != 0); - SetStart(thread, JSTaggedValue((start + 1) % capacity)); - return value; -} -} // namespace panda::ecmascript -#endif // ECMASCRIPT_TAGGED_QUEUE_INL_H \ No newline at end of file diff --git a/ecmascript/tagged_queue.h b/ecmascript/tagged_queue.h index 442544e45e..f880bb517a 100644 --- a/ecmascript/tagged_queue.h +++ b/ecmascript/tagged_queue.h @@ -29,7 +29,21 @@ public: return reinterpret_cast(object); } - JSTaggedValue Pop(JSThread *thread); + inline JSTaggedValue Pop(JSThread *thread) + { + if (Empty()) { + return JSTaggedValue::Hole(); + } + + uint32_t start = GetStart().GetArrayLength(); + JSTaggedValue value = Get(start); + + uint32_t capacity = GetCapacity().GetArrayLength(); + ASSERT(capacity != 0); + SetStart(thread, JSTaggedValue((start + 1) % capacity)); + return value; + } + static TaggedQueue *Push(const JSThread *thread, const JSHandle &queue, const JSHandle &value) { @@ -175,7 +189,17 @@ private: return TaggedArray::Get(END_INDEX); } - static TaggedQueue *Create(JSThread *thread, uint32_t capacity, JSTaggedValue initVal = JSTaggedValue::Hole()); + static inline TaggedQueue *Create(JSThread *thread, uint32_t capacity, + JSTaggedValue initVal = JSTaggedValue::Hole()) + { + uint32_t length = QueueToArrayIndex(capacity); + + auto queue = TaggedQueue::Cast(*thread->GetEcmaVM()->GetFactory()->NewTaggedArray(length, initVal)); + queue->SetStart(thread, JSTaggedValue(0)); // equal to 0 when add 1. + queue->SetEnd(thread, JSTaggedValue(0)); + queue->SetCapacity(thread, JSTaggedValue(capacity)); + return queue; + } }; } // namespace panda::ecmascript #endif // ECMASCRIPT_TAGGED_QUEUE_H \ No newline at end of file diff --git a/ecmascript/tests/assert_scope_test.cpp b/ecmascript/tests/assert_scope_test.cpp index f580812901..9848e73960 100644 --- a/ecmascript/tests/assert_scope_test.cpp +++ b/ecmascript/tests/assert_scope_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/tests/test_helper.h" using namespace panda::ecmascript; diff --git a/ecmascript/tests/dump_test.cpp b/ecmascript/tests/dump_test.cpp index dcdb3f0df3..7300806f0d 100644 --- a/ecmascript/tests/dump_test.cpp +++ b/ecmascript/tests/dump_test.cpp @@ -34,7 +34,7 @@ #include "ecmascript/js_api_stack.h" #include "ecmascript/js_api_stack_iterator.h" #include "ecmascript/jspandafile/class_info_extractor.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_api_tree_map.h" #include "ecmascript/js_api_tree_map_iterator.h" #include "ecmascript/js_api_tree_set.h" @@ -80,7 +80,7 @@ #include "ecmascript/layout_info-inl.h" #include "ecmascript/lexical_env.h" #include "ecmascript/linked_hash_table-inl.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ecmascript/mem/assert_scope.h" #include "ecmascript/mem/c_containers.h" #include "ecmascript/mem/machine_code.h" #include "ecmascript/module/js_module_source_text.h" diff --git a/ecmascript/tests/js_object_test.cpp b/ecmascript/tests/js_object_test.cpp index ab788f4368..02c01e51d8 100644 --- a/ecmascript/tests/js_object_test.cpp +++ b/ecmascript/tests/js_object_test.cpp @@ -30,7 +30,7 @@ #include "ecmascript/tagged_array-inl.h" #include "ecmascript/tagged_dictionary.h" #include "ecmascript/tests/test_helper.h" -#include "ecmascript/weak_vector-inl.h" +#include "ecmascript/weak_vector.h" using namespace panda::ecmascript; using namespace panda::ecmascript::base; diff --git a/ecmascript/tests/js_tagged_queue_test.cpp b/ecmascript/tests/js_tagged_queue_test.cpp index 58bb41cef7..0805bb9b88 100644 --- a/ecmascript/tests/js_tagged_queue_test.cpp +++ b/ecmascript/tests/js_tagged_queue_test.cpp @@ -19,7 +19,7 @@ #include "ecmascript/js_handle.h" #include "ecmascript/object_factory.h" #include "ecmascript/snapshot/mem/snapshot.h" -#include "ecmascript/tagged_queue-inl.h" +#include "ecmascript/tagged_queue.h" #include "ecmascript/tagged_queue.h" #include "ecmascript/tests/test_helper.h" diff --git a/ecmascript/tests/symbol_table_test.cpp b/ecmascript/tests/symbol_table_test.cpp index 18a07de060..561356d97a 100644 --- a/ecmascript/tests/symbol_table_test.cpp +++ b/ecmascript/tests/symbol_table_test.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "ecmascript/symbol_table-inl.h" +#include "ecmascript/symbol_table.h" #include "ecmascript/ecma_string.h" #include "ecmascript/js_symbol.h" #include "ecmascript/object_factory.h" diff --git a/ecmascript/tooling/interface/debugger_api.cpp b/ecmascript/tooling/interface/debugger_api.cpp index 8da1eeb37a..d74a525e8f 100644 --- a/ecmascript/tooling/interface/debugger_api.cpp +++ b/ecmascript/tooling/interface/debugger_api.cpp @@ -17,11 +17,12 @@ #include "ecmascript/base/number_helper.h" #include "ecmascript/interpreter/frame_handler.h" -#include "ecmascript/jspandafile/program_object-inl.h" +#include "ecmascript/jspandafile/program_object.h" #include "ecmascript/js_handle.h" #include "ecmascript/js_method.h" #include "ecmascript/jspandafile/js_pandafile_manager.h" -#include "ecmascript/napi/jsnapi_helper-inl.h" +#include "ecmascript/mem/c_string.h" +#include "ecmascript/napi/jsnapi_helper.h" #include "ecmascript/tooling/interface/js_debugger.h" namespace panda::tooling::ecmascript { diff --git a/ecmascript/ts_types/tests/ts_type_test.cpp b/ecmascript/ts_types/tests/ts_type_test.cpp index 8a7b205b1e..38bb8422af 100644 --- a/ecmascript/ts_types/tests/ts_type_test.cpp +++ b/ecmascript/ts_types/tests/ts_type_test.cpp @@ -19,7 +19,7 @@ #include "ecmascript/object_factory.h" #include "ecmascript/tests/test_helper.h" #include "ecmascript/ts_types/ts_type_table.h" -#include "ecmascript/ts_types/ts_obj_layout_info-inl.h" +#include "ecmascript/ts_types/ts_obj_layout_info.h" using namespace panda::ecmascript; namespace panda::test { diff --git a/ecmascript/ts_types/ts_obj_layout_info-inl.h b/ecmascript/ts_types/ts_obj_layout_info-inl.h deleted file mode 100644 index 71f3690728..0000000000 --- a/ecmascript/ts_types/ts_obj_layout_info-inl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_TS_TYPES_TS_OBJ_LAYOUT_INFO_INL_H -#define ECMASCRIPT_TS_TYPES_TS_OBJ_LAYOUT_INFO_INL_H - -#include "ts_obj_layout_info.h" -#include "ecmascript/tagged_array-inl.h" - -namespace panda::ecmascript { -inline uint32_t TSObjLayoutInfo::GetPropertiesCapacity() const -{ - return static_cast((GetLength() - ELEMENTS_START_INDEX) / ENTRY_SIZE); -} - -inline void TSObjLayoutInfo::SetNumberOfElements(const JSThread *thread, int propertiesNum) -{ - return TaggedArray::Set(thread, ELEMENTS_COUNT_INDEX, JSTaggedValue(propertiesNum)); -} - -inline uint32_t TSObjLayoutInfo::NumberOfElements() const -{ - return TaggedArray::Get(ELEMENTS_COUNT_INDEX).GetInt(); -} - -inline uint32_t TSObjLayoutInfo::GetKeyIndex(int index) const -{ - return ELEMENTS_START_INDEX + (static_cast(index) * ENTRY_SIZE + ENTRY_KEY_OFFSET); -} - -inline uint32_t TSObjLayoutInfo::GetTypeIdIndex(int index) const -{ - return ELEMENTS_START_INDEX + (static_cast(index) * ENTRY_SIZE) + ENTRY_TYPE_OFFSET; -} - -inline void TSObjLayoutInfo::SetPropertyInit(const JSThread *thread, int index, const JSTaggedValue &key, - const JSTaggedValue &tsTypeId) -{ - uint32_t idxInArray = GetKeyIndex(index); - TaggedArray::Set(thread, idxInArray + ENTRY_KEY_OFFSET, key); - TaggedArray::Set(thread, idxInArray + ENTRY_TYPE_OFFSET, tsTypeId); -} - -inline JSTaggedValue TSObjLayoutInfo::GetKey(int index) const -{ - uint32_t idxInArray = GetKeyIndex(index); - return TaggedArray::Get(idxInArray); -} - -inline JSTaggedValue TSObjLayoutInfo::GetTypeId(int index) const -{ - uint32_t idxInArray = GetTypeIdIndex(index); - return TaggedArray::Get(idxInArray); -} -} // namespace panda::ecmascript -#endif // ECMASCRIPT_TS_TYPES_TS_OBJ_LAYOUT_INFO_INL_H \ No newline at end of file diff --git a/ecmascript/ts_types/ts_obj_layout_info.cpp b/ecmascript/ts_types/ts_obj_layout_info.cpp index 8eab5ed4bd..2e048f26d4 100644 --- a/ecmascript/ts_types/ts_obj_layout_info.cpp +++ b/ecmascript/ts_types/ts_obj_layout_info.cpp @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "ts_obj_layout_info-inl.h" -#include "ecmascript/mem/assert_scope-inl.h" +#include "ts_obj_layout_info.h" +#include "ecmascript/mem/assert_scope.h" namespace panda::ecmascript { void TSObjLayoutInfo::SetKey(const JSThread *thread, [[maybe_unused]] int index, const JSTaggedValue &key, diff --git a/ecmascript/ts_types/ts_obj_layout_info.h b/ecmascript/ts_types/ts_obj_layout_info.h index c34eb0e9b8..d3d48b24f3 100644 --- a/ecmascript/ts_types/ts_obj_layout_info.h +++ b/ecmascript/ts_types/ts_obj_layout_info.h @@ -17,7 +17,7 @@ #define ECMASCRIPT_TS_TYPES_TS_OBJ_LAYOUT_INFO_H #include "ecmascript/js_object.h" -#include "ecmascript/tagged_array.h" +#include "ecmascript/tagged_array-inl.h" namespace panda::ecmascript { // TSObjLayoutInfo contains keys and TsTypeId of Properties. @@ -38,12 +38,41 @@ public: return reinterpret_cast(obj); } - uint32_t GetPropertiesCapacity() const; - void SetNumberOfElements(const JSThread *thread, int propertiesNum); - uint32_t NumberOfElements() const; - void SetPropertyInit(const JSThread *thread, int index, const JSTaggedValue &key, const JSTaggedValue &tsTypeId); - JSTaggedValue GetKey(int index) const; - JSTaggedValue GetTypeId(int index) const; + inline uint32_t GetPropertiesCapacity() const + { + return static_cast((GetLength() - ELEMENTS_START_INDEX) / ENTRY_SIZE); + } + + inline void SetNumberOfElements(const JSThread *thread, int propertiesNum) + { + return TaggedArray::Set(thread, ELEMENTS_COUNT_INDEX, JSTaggedValue(propertiesNum)); + } + + inline uint32_t NumberOfElements() const + { + return TaggedArray::Get(ELEMENTS_COUNT_INDEX).GetInt(); + } + + inline void SetPropertyInit(const JSThread *thread, int index, const JSTaggedValue &key, + const JSTaggedValue &tsTypeId) + { + uint32_t idxInArray = GetKeyIndex(index); + TaggedArray::Set(thread, idxInArray + ENTRY_KEY_OFFSET, key); + TaggedArray::Set(thread, idxInArray + ENTRY_TYPE_OFFSET, tsTypeId); + } + + inline JSTaggedValue GetKey(int index) const + { + uint32_t idxInArray = GetKeyIndex(index); + return TaggedArray::Get(idxInArray); + } + + inline JSTaggedValue GetTypeId(int index) const + { + uint32_t idxInArray = GetTypeIdIndex(index); + return TaggedArray::Get(idxInArray); + } + void SetKey(const JSThread *thread, int index, const JSTaggedValue &key, const JSTaggedValue &typeId); inline uint32_t GetLength() const @@ -56,11 +85,16 @@ public: return (properties_number * ENTRY_SIZE) + ELEMENTS_START_INDEX; } - int FindElement(JSTaggedValue key, int propertiesNumber); - private: - uint32_t GetKeyIndex(int index) const; - uint32_t GetTypeIdIndex(int index) const; + inline uint32_t GetKeyIndex(int index) const + { + return ELEMENTS_START_INDEX + (static_cast(index) * ENTRY_SIZE + ENTRY_KEY_OFFSET); + } + + inline uint32_t GetTypeIdIndex(int index) const + { + return ELEMENTS_START_INDEX + (static_cast(index) * ENTRY_SIZE) + ENTRY_TYPE_OFFSET; + } static inline uint32_t ComputeGrowCapacity(uint32_t old_capacity) { diff --git a/ecmascript/ts_types/ts_type.cpp b/ecmascript/ts_types/ts_type.cpp index b97dcfa00c..4d8cf72b68 100644 --- a/ecmascript/ts_types/ts_type.cpp +++ b/ecmascript/ts_types/ts_type.cpp @@ -20,7 +20,7 @@ #include "ecmascript/js_handle.h" #include "ecmascript/js_hclass.h" #include "ecmascript/object_factory.h" -#include "ecmascript/ts_types/ts_obj_layout_info-inl.h" +#include "ecmascript/ts_types/ts_obj_layout_info.h" #include "ecmascript/ts_types/ts_type_table.h" namespace panda::ecmascript { diff --git a/ecmascript/ts_types/ts_type_table.cpp b/ecmascript/ts_types/ts_type_table.cpp index ef07d18fba..04baa9ad57 100644 --- a/ecmascript/ts_types/ts_type_table.cpp +++ b/ecmascript/ts_types/ts_type_table.cpp @@ -20,7 +20,7 @@ #include "ecmascript/jspandafile/program_object.h" #include "ecmascript/object_factory.h" #include "ecmascript/ts_types/ts_loader.h" -#include "ecmascript/ts_types/ts_obj_layout_info-inl.h" +#include "ecmascript/ts_types/ts_obj_layout_info.h" namespace panda::ecmascript { void TSTypeTable::Initialize(JSThread *thread, const JSPandaFile *jsPandaFile, diff --git a/ecmascript/weak_vector-inl.h b/ecmascript/weak_vector-inl.h deleted file mode 100644 index 7e515d0f3b..0000000000 --- a/ecmascript/weak_vector-inl.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMASCRIPT_WEAK_VECTOR_INL_H -#define ECMASCRIPT_WEAK_VECTOR_INL_H - -#include "weak_vector.h" -#include "tagged_array-inl.h" - -namespace panda::ecmascript { -uint32_t WeakVector::GetEnd() const -{ - return TaggedArray::Get(END_INDEX).GetArrayLength(); -} - -bool WeakVector::Full() const -{ - return GetEnd() == GetCapacity(); -} - -bool WeakVector::Empty() const -{ - return GetEnd() == 0; -} - -uint32_t WeakVector::GetCapacity() const -{ - return TaggedArray::GetLength() - ELEMENTS_START_INDEX; -} - -JSTaggedValue WeakVector::Get(uint32_t index) const -{ - ASSERT(index < GetCapacity()); - return TaggedArray::Get(VectorToArrayIndex(index)); -} - -void WeakVector::Set(const JSThread *thread, uint32_t index, JSTaggedValue value) -{ - ASSERT(index < GetCapacity()); - TaggedArray::Set(thread, VectorToArrayIndex(index), value); -} - -void WeakVector::SetEnd(const JSThread *thread, uint32_t end) -{ - ASSERT(end <= GetCapacity()); - TaggedArray::Set(thread, END_INDEX, JSTaggedValue(end)); -} -} // namespace panda::ecmascript -#endif // ECMASCRIPT_WEAK_VECTOR_INL_H \ No newline at end of file diff --git a/ecmascript/weak_vector.cpp b/ecmascript/weak_vector.cpp index 2cade2e4a6..b2a42a62eb 100644 --- a/ecmascript/weak_vector.cpp +++ b/ecmascript/weak_vector.cpp @@ -13,9 +13,9 @@ * limitations under the License. */ -#include "weak_vector.h" +#include "ecmascript/weak_vector.h" + #include "ecmascript/object_factory.h" -#include "ecmascript/weak_vector-inl.h" namespace panda::ecmascript { JSHandle WeakVector::Create(const JSThread *thread, uint32_t capacity) diff --git a/ecmascript/weak_vector.h b/ecmascript/weak_vector.h index 5eb61ea6c9..bab4363db4 100644 --- a/ecmascript/weak_vector.h +++ b/ecmascript/weak_vector.h @@ -18,7 +18,7 @@ #include "ecmascript/js_handle.h" #include "ecmascript/js_thread.h" -#include "ecmascript/tagged_array.h" +#include "ecmascript/tagged_array-inl.h" namespace panda::ecmascript { class WeakVector : public TaggedArray { @@ -35,17 +35,37 @@ public: // just set index value to Hole bool Delete(const JSThread *thread, uint32_t index); - inline uint32_t GetEnd() const; + inline uint32_t GetEnd() const + { + return TaggedArray::Get(END_INDEX).GetArrayLength(); + } - inline bool Full() const; + inline bool Full() const + { + return GetEnd() == GetCapacity(); + } - inline bool Empty() const; + inline bool Empty() const + { + return GetEnd() == 0; + } - inline uint32_t GetCapacity() const; + inline uint32_t GetCapacity() const + { + return TaggedArray::GetLength() - ELEMENTS_START_INDEX; + } - inline JSTaggedValue Get(uint32_t index) const; + inline JSTaggedValue Get(uint32_t index) const + { + ASSERT(index < GetCapacity()); + return TaggedArray::Get(VectorToArrayIndex(index)); + } - inline void Set(const JSThread *thread, uint32_t index, JSTaggedValue value); + inline void Set(const JSThread *thread, uint32_t index, JSTaggedValue value) + { + ASSERT(index < GetCapacity()); + TaggedArray::Set(thread, VectorToArrayIndex(index), value); + } private: static const uint32_t MIN_CAPACITY = 2; @@ -58,7 +78,11 @@ private: return index + ELEMENTS_START_INDEX; } - inline void SetEnd(const JSThread *thread, uint32_t end); + inline void SetEnd(const JSThread *thread, uint32_t end) + { + ASSERT(end <= GetCapacity()); + TaggedArray::Set(thread, END_INDEX, JSTaggedValue(end)); + } }; } // namespace panda::ecmascript #endif // ECMASCRIPT_WEAK_VECTOR_H -- Gitee