From 0cb996200a5e6c40f99df813cdda69ec2ae0eea0 Mon Sep 17 00:00:00 2001 From: vagin ivan Date: Tue, 12 Jul 2022 16:49:04 +0300 Subject: [PATCH] Move out clang-format from cmake Change-Id: Ic3372931952ec56b3c4d3659f3c6d4bbfd45615b Signed-off-by: vagin ivan --- bytecode_optimizer/CMakeLists.txt | 2 - compiler/CMakeLists.txt | 2 - compiler/ecmascript_extensions/CMakeLists.txt | 2 - runtime/asm_defines/defines.h | 26 +- runtime/base/error_helper.h | 1 + runtime/base/gc_ring_buffer.h | 4 +- runtime/base/json_parser.cpp | 3 +- runtime/base/json_parser.h | 81 +- runtime/base/json_stringifier.h | 4 +- runtime/base/number_helper.cpp | 2 +- runtime/base/object_helper.cpp | 2 +- runtime/base/string_helper.cpp | 28 +- runtime/base/string_helper.h | 19 +- runtime/base/utf_helper.cpp | 2 +- runtime/builtins.cpp | 5 +- runtime/builtins/builtins_async_generator.cpp | 9 +- runtime/builtins/builtins_generator.cpp | 6 +- runtime/builtins/builtins_global.cpp | 3 +- runtime/builtins/builtins_math.cpp | 3 +- runtime/builtins/builtins_number.cpp | 10 +- runtime/builtins/builtins_regexp.cpp | 8 +- runtime/builtins/builtins_string_iterator.cpp | 3 +- runtime/builtins/builtins_typedarray.cpp | 4 +- runtime/builtins/builtins_weak_map.cpp | 4 +- runtime/class_info_extractor.h | 5 +- runtime/common.h | 2 +- runtime/containers/containers_private.h | 17 +- runtime/ecma_class_linker_extension.cpp | 7 +- runtime/ecma_class_linker_extension.h | 2 +- runtime/ecma_global_storage.h | 14 +- runtime/ecma_handle_scope-inl.h | 4 +- runtime/ecma_handle_scope.h | 2 +- runtime/ecma_macros.h | 2 +- runtime/ecma_module.cpp | 6 +- runtime/ecma_module.h | 6 +- runtime/ecma_string-inl.h | 2 +- runtime/ecma_string.h | 12 +- runtime/ecma_string_table.cpp | 3 +- runtime/ecma_string_table.h | 2 +- runtime/global_dictionary-inl.h | 3 +- runtime/global_env_constants.h | 4 +- runtime/global_handle_collection.h | 8 +- runtime/hprof/heap_profiler.h | 2 +- runtime/hprof/heap_profiler_interface.cpp | 4 +- runtime/hprof/heap_profiler_interface.h | 5 +- .../hprof/heap_snapshot_json_serializer.cpp | 4 +- runtime/hprof/heap_snapshot_json_serializer.h | 2 +- runtime/hprof/string_hashmap.h | 2 +- runtime/ic/ic_binary_op.h | 16 +- runtime/ic/ic_compare_op.cpp | 158 ++-- runtime/ic/ic_compare_op.h | 31 +- runtime/ic/ic_handler-inl.h | 6 +- runtime/ic/invoke_cache.h | 3 +- runtime/ic/profile_type_info.h | 6 +- runtime/ic/properties_cache.h | 8 +- runtime/ic/proto_change_details.h | 1 - runtime/internal_call_params.cpp | 5 +- runtime/internal_call_params.h | 18 +- runtime/interpreter/fast_runtime_stub.h | 17 +- runtime/interpreter/interpreter-inl.h | 8 +- runtime/interpreter/interpreter.h | 8 +- runtime/interpreter/js_frame-inl.h | 4 +- runtime/jobs/micro_job_queue.cpp | 2 +- runtime/jobs/micro_job_queue.h | 2 +- runtime/js_arraylist.cpp | 4 +- runtime/js_collator.h | 4 +- runtime/js_date.cpp | 38 +- runtime/js_invoker.h | 6 +- runtime/js_number_format.cpp | 5 +- runtime/js_number_format.h | 24 +- runtime/js_object.h | 13 +- runtime/js_plural_rules.cpp | 15 +- runtime/js_plural_rules.h | 9 +- runtime/js_proxy.h | 2 +- runtime/js_stable_array.cpp | 7 +- runtime/js_stable_array.h | 4 +- runtime/js_typed_array.cpp | 4 +- runtime/js_typed_array.h | 6 +- runtime/layout_info.cpp | 6 +- runtime/linked_hash_table-inl.h | 56 +- runtime/linked_hash_table.h | 2 +- runtime/mem/allocator.h | 2 +- runtime/mem/area.h | 2 +- runtime/mem/assert_scope-inl.h | 6 +- runtime/mem/assert_scope.h | 4 +- runtime/mem/barriers-inl.h | 4 +- runtime/mem/barriers.h | 2 +- runtime/mem/c_containers.h | 18 +- runtime/mem/c_string.cpp | 2 +- runtime/mem/caddress_allocator.h | 16 +- runtime/mem/chunk.h | 16 +- runtime/mem/chunk_allocator.h | 14 +- runtime/mem/chunk_containers.h | 8 +- runtime/mem/clock_scope.h | 4 +- runtime/mem/compress_collector.cpp | 5 +- runtime/mem/concurrent_marker.cpp | 15 +- runtime/mem/concurrent_marker.h | 6 +- runtime/mem/concurrent_sweeper.cpp | 25 +- runtime/mem/concurrent_sweeper.h | 2 +- runtime/mem/ecma_list.h | 4 +- runtime/mem/evacuation_allocator.h | 6 +- runtime/mem/free_object_list.cpp | 13 +- runtime/mem/free_object_list.h | 6 +- runtime/mem/heap-inl.h | 31 +- runtime/mem/machine_code.h | 4 +- runtime/mem/mark_stack-inl.h | 8 +- runtime/mem/mark_stack.h | 18 +- runtime/mem/mark_word.h | 2 +- runtime/mem/mem.h | 6 +- runtime/mem/mem_manager.cpp | 4 +- runtime/mem/mix_space_collector.cpp | 16 +- runtime/mem/object_xray-inl.h | 2 +- runtime/mem/object_xray.h | 2 +- runtime/mem/parallel_marker.cpp | 25 +- runtime/mem/parallel_marker.h | 10 +- runtime/mem/parallel_work_helper.cpp | 4 +- runtime/mem/parallel_work_helper.h | 4 +- runtime/mem/region-inl.h | 6 +- runtime/mem/region.h | 25 +- runtime/mem/region_factory.cpp | 4 +- runtime/mem/region_factory.h | 6 +- runtime/mem/remembered_set.h | 4 +- runtime/mem/semi_space_collector.h | 4 +- runtime/mem/space-inl.h | 6 +- runtime/mem/space.cpp | 4 +- runtime/mem/space.h | 3 +- runtime/mem/tagged_object.h | 4 +- runtime/mem/tlab_allocator-inl.h | 10 +- runtime/mem/verification.h | 5 +- runtime/message_string.cpp | 2 +- runtime/message_string.h | 2 +- runtime/napi/jsnapi_helper-inl.h | 2 +- runtime/napi/jsnapi_helper.h | 2 +- runtime/object_operator.cpp | 2 +- runtime/object_operator.h | 16 +- runtime/property_attributes.h | 8 +- runtime/regexp/regexp_executor.cpp | 6 +- runtime/regexp/regexp_opcode.h | 6 +- runtime/regexp/regexp_parser_cache.cpp | 6 +- runtime/regexp/regexp_parser_cache.h | 10 +- runtime/runtime_call_id.h | 12 +- runtime/snapshot/mem/snapshot.cpp | 2 +- runtime/snapshot/mem/snapshot.h | 3 +- runtime/snapshot/mem/snapshot_serialize.h | 24 +- runtime/tagged_array-inl.h | 2 +- runtime/tagged_array.h | 5 +- runtime/tagged_hash_table-inl.h | 66 +- runtime/tagged_hash_table.h | 4 +- runtime/vmstat/caller_stat.h | 16 +- runtime/vmstat/runtime_stat.cpp | 9 +- runtime/vmstat/runtime_stat.h | 8 +- .../reg_encoder_test_ecmascript.cpp | 15 +- .../runtime/builtins/builtins_array_test.cpp | 26 +- .../builtins/builtins_arraybuffer_test.cpp | 2 +- tests/runtime/builtins/builtins_date_test.cpp | 2 +- tests/runtime/builtins/builtins_json_test.cpp | 14 +- .../runtime/builtins/builtins_number_test.cpp | 6 +- .../runtime/builtins/builtins_object_test.cpp | 1 - .../builtins/builtins_typedarray_test.cpp | 4 +- .../builtins/builtins_weak_set_test.cpp | 3 +- tests/runtime/common/ecma_module_test.cpp | 76 +- tests/runtime/common/ecma_string_test.cpp | 691 +++++++++--------- tests/runtime/common/huge_object_test.cpp | 7 +- .../runtime/common/js_array_iterator_test.cpp | 26 +- tests/runtime/common/js_dataview_test.cpp | 14 +- tests/runtime/common/js_handle_test.cpp | 18 +- tests/runtime/common/js_serializer_test.cpp | 52 +- tests/runtime/common/mem_controller_test.cpp | 20 +- tests/runtime/common/object_factory_test.cpp | 2 +- tests/runtime/common/symbol_table_test.cpp | 18 +- tests/runtime/common/test_helper.h | 3 +- .../common/visitor_compatibility_tests.cpp | 11 +- tests/runtime/hprof/heap_tracker_test.cpp | 2 +- tests/runtime/ic/ic_binaryop_test.cpp | 87 ++- tests/runtime/ic/ic_compareop_test.cpp | 305 ++++---- tests/runtime/ic/ic_invoke_test.cpp | 10 +- tests/runtime/mem/g1gc_barrier_test.cpp | 12 +- tests/runtime/mem/weak_containers_test.cpp | 7 +- tests/runtime/napi/jsnapi_tests.cpp | 12 +- tests/runtime/snapshot/snapshot_test.cpp | 6 +- tests/runtime/tooling/CMakeLists.txt | 2 - 181 files changed, 1414 insertions(+), 1501 deletions(-) diff --git a/bytecode_optimizer/CMakeLists.txt b/bytecode_optimizer/CMakeLists.txt index 4ed90cb3e..0dc92c095 100644 --- a/bytecode_optimizer/CMakeLists.txt +++ b/bytecode_optimizer/CMakeLists.txt @@ -29,5 +29,3 @@ add_dependencies(arkbytecodeopt isa_gen_${PROJECT_NAME}) target_include_directories(arkbytecodeopt PUBLIC ${GENERATED_DIR} ) - -add_check_style(".") diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt index 39330c15c..214677c82 100644 --- a/compiler/CMakeLists.txt +++ b/compiler/CMakeLists.txt @@ -42,5 +42,3 @@ target_include_directories(arkcompiler PUBLIC ) add_inst_templates(${CMAKE_CURRENT_SOURCE_DIR}/optimizer/ir_builder/ecmascript_inst_templates.yaml) - -add_check_style(".") diff --git a/compiler/ecmascript_extensions/CMakeLists.txt b/compiler/ecmascript_extensions/CMakeLists.txt index 59c86668a..ec535e552 100644 --- a/compiler/ecmascript_extensions/CMakeLists.txt +++ b/compiler/ecmascript_extensions/CMakeLists.txt @@ -14,5 +14,3 @@ set(COMPILER_SOURCES ${PANDA_ECMASCRIPT_PLUGIN_SOURCE}/compiler/ecmascript_extensions/ecmascript_codegen_extensions.cpp) target_sources(arkcompiler PRIVATE ${COMPILER_SOURCES}) - -add_check_style(".") diff --git a/runtime/asm_defines/defines.h b/runtime/asm_defines/defines.h index fc02bf404..975128eb9 100644 --- a/runtime/asm_defines/defines.h +++ b/runtime/asm_defines/defines.h @@ -1,17 +1,17 @@ /* -* Copyright (c) 2021-2022 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. -*/ + * Copyright (c) 2021-2022 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 PLUGINS_ECMASCRIPT_RUNTIME_ASM_DEFINES_DEFINES_H #define PLUGINS_ECMASCRIPT_RUNTIME_ASM_DEFINES_DEFINES_H diff --git a/runtime/base/error_helper.h b/runtime/base/error_helper.h index 34e584cbf..46b1c071d 100644 --- a/runtime/base/error_helper.h +++ b/runtime/base/error_helper.h @@ -32,6 +32,7 @@ public: static JSTaggedValue ErrorCommonConstructor(EcmaRuntimeCallInfo *argv, const ErrorType &errorType); static CString BuildNativeEcmaStackTrace(JSThread *thread); + private: static CString DecodeFunctionName(const CString &name); static JSHandle BuildEcmaStackTrace(JSThread *thread); diff --git a/runtime/base/gc_ring_buffer.h b/runtime/base/gc_ring_buffer.h index 372fb5e24..dca89bed2 100644 --- a/runtime/base/gc_ring_buffer.h +++ b/runtime/base/gc_ring_buffer.h @@ -24,7 +24,7 @@ namespace panda::ecmascript::base { // GC Ring Buffer is base tool class. It will be used to collect the data of the last N GCs. The max length is // fixed, so we call it a GC ring buffer. In this class, we define the functions to push data, count the length, // return the sum and reset data. -template +template class GCRingBuffer { public: GCRingBuffer() = default; @@ -52,7 +52,7 @@ public: // This function will return the sum of the elements_. The parameter callback // should define the sum function of data type T. - template + template T Sum(Callback callback, const T &initial) const { T result = initial; diff --git a/runtime/base/json_parser.cpp b/runtime/base/json_parser.cpp index f24b6a04a..0b033388c 100644 --- a/runtime/base/json_parser.cpp +++ b/runtime/base/json_parser.cpp @@ -48,7 +48,8 @@ JSHandle Internalize::InternalizeJsonProperty(JSThread *thread, c JSMutableHandle keyName(thread, JSTaggedValue::Undefined()); for (uint32_t i = 0; i < namesLength; i++) { keyName.Update(JSTaggedValue::GetProperty(thread, JSHandle(ownerNames), i) - .GetValue().GetTaggedValue()); + .GetValue() + .GetTaggedValue()); RecurseAndApply(thread, obj, keyName, receiver); } } diff --git a/runtime/base/json_parser.h b/runtime/base/json_parser.h index d5747a11b..82f650eb1 100644 --- a/runtime/base/json_parser.h +++ b/runtime/base/json_parser.h @@ -39,18 +39,18 @@ constexpr unsigned int NUMBER_SIXTEEN = 16; constexpr unsigned char CODE_SPACE = 0x20; constexpr unsigned char ASCII_END = 0X7F; enum class Tokens : uint8_t { - // six structural tokens - OBJECT = 0, - ARRAY, - NUMBER, - STRING, - LITERAL_TRUE, - LITERAL_FALSE, - LITERAL_NULL, - TOKEN_ILLEGAL, - }; - -template + // six structural tokens + OBJECT = 0, + ARRAY, + NUMBER, + STRING, + LITERAL_TRUE, + LITERAL_FALSE, + LITERAL_NULL, + TOKEN_ILLEGAL, +}; + +template class JsonParser { public: using Text = const T *; @@ -96,7 +96,7 @@ public: } private: - template + template JSTaggedValue ParseJSONText() { SkipStartWhiteSpace(); @@ -121,7 +121,7 @@ private: } } - template + template JSTaggedValue ParseNumber() { if (inObjOrArr) { @@ -245,7 +245,7 @@ private: .GetTaggedValue(); } - template + template JSTaggedValue ParseString() { bool isFastString = true; @@ -260,13 +260,17 @@ private: if (isAscii) { CString value(current_, end_); current_ = end_; - return factory_->NewFromUtf8LiteralUnCheck( - reinterpret_cast(value.c_str()), value.length(), true).GetTaggedValue(); + return factory_ + ->NewFromUtf8LiteralUnCheck(reinterpret_cast(value.c_str()), value.length(), + true) + .GetTaggedValue(); } std::u16string value(current_, end_); current_ = end_; - return factory_->NewFromUtf16LiteralUnCheck( - reinterpret_cast(value.c_str()), value.length(), false).GetTaggedValue(); + return factory_ + ->NewFromUtf16LiteralUnCheck(reinterpret_cast(value.c_str()), value.length(), + false) + .GetTaggedValue(); } } else { if (*end_ != '"' || current_ == end_) { @@ -279,18 +283,22 @@ private: if (LIKELY(isFastString)) { if (isAscii) { CString value(current_, end_); - return factory_->NewFromUtf8LiteralUnCheck( - reinterpret_cast(value.c_str()), value.length(), true).GetTaggedValue(); + return factory_ + ->NewFromUtf8LiteralUnCheck(reinterpret_cast(value.c_str()), value.length(), + true) + .GetTaggedValue(); } std::u16string value(current_, end_); - return factory_->NewFromUtf16LiteralUnCheck( - reinterpret_cast(value.c_str()), value.length(), false).GetTaggedValue(); + return factory_ + ->NewFromUtf16LiteralUnCheck(reinterpret_cast(value.c_str()), value.length(), + false) + .GetTaggedValue(); } } return SlowParseString(); } - template + template JSTaggedValue ParseArray() { if (UNLIKELY(*range_ != ']' && !inObjorArr)) { @@ -316,13 +324,13 @@ private: if (inObjorArr || current_ == range_) { return arr.GetTaggedValue(); } - THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Array in JSON", JSTaggedValue::Exception()); + THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Array in JSON", JSTaggedValue::Exception()); } } THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Array in JSON", JSTaggedValue::Exception()); } - template + template JSTaggedValue ParseObject() { if (UNLIKELY(*range_ != '}' && !inObjorArr)) { @@ -355,8 +363,8 @@ private: THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Object in JSON", JSTaggedValue::Exception()); } value = ParseJSONText(); - FastRuntimeStub::SetPropertyByValue( - thread_, result.GetTaggedValue(), keyHandle.GetTaggedValue(), value); + FastRuntimeStub::SetPropertyByValue(thread_, result.GetTaggedValue(), keyHandle.GetTaggedValue(), + value); GetNextNonSpaceChar(); if (*current_ == ',') { current_++; @@ -364,7 +372,7 @@ private: if (inObjorArr || current_ == range_) { return result.GetTaggedValue(); } - THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Object in JSON", JSTaggedValue::Exception()); + THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Object in JSON", JSTaggedValue::Exception()); } } THROW_SYNTAX_ERROR_AND_RETURN(thread_, "Unexpected Object in JSON", JSTaggedValue::Exception()); @@ -744,13 +752,13 @@ private: return true; } - bool isAsciiString_{false}; - Text end_{nullptr}; - Text current_{nullptr}; - Text range_{nullptr}; - JSThread *thread_{nullptr}; - ObjectFactory *factory_{nullptr}; - GlobalEnv *env_{nullptr}; + bool isAsciiString_ {false}; + Text end_ {nullptr}; + Text current_ {nullptr}; + Text range_ {nullptr}; + JSThread *thread_ {nullptr}; + ObjectFactory *factory_ {nullptr}; + GlobalEnv *env_ {nullptr}; }; class Internalize { @@ -758,6 +766,7 @@ public: static JSHandle InternalizeJsonProperty(JSThread *thread, const JSHandle &holder, const JSHandle &name, const JSHandle &receiver); + private: static bool RecurseAndApply(JSThread *thread, const JSHandle &holder, const JSHandle &name, const JSHandle &receiver); diff --git a/runtime/base/json_stringifier.h b/runtime/base/json_stringifier.h index 68399af06..bdc0b784f 100644 --- a/runtime/base/json_stringifier.h +++ b/runtime/base/json_stringifier.h @@ -28,7 +28,9 @@ public: explicit JsonStringifier(JSThread *thread) : thread_(thread), handleKey_(thread, JSTaggedValue::Undefined()), - handleValue_(thread, JSTaggedValue::Undefined()) {} + handleValue_(thread, JSTaggedValue::Undefined()) + { + } ~JsonStringifier() = default; NO_COPY_SEMANTIC(JsonStringifier); diff --git a/runtime/base/number_helper.cpp b/runtime/base/number_helper.cpp index e97a28dc1..0ac85a0b1 100644 --- a/runtime/base/number_helper.cpp +++ b/runtime/base/number_helper.cpp @@ -140,7 +140,7 @@ JSTaggedValue NumberHelper::DoubleToExponential(JSThread *thread, double number, CString result = ss.str(); size_t found = result.find_last_of('e'); if (found != CString::npos && found < result.size() - 2 && result[found + 2] == '0') { - result.erase(found + 2, 1); // 2:offset of e + result.erase(found + 2, 1); // 2:offset of e } if (digit < 0) { size_t end = found; diff --git a/runtime/base/object_helper.cpp b/runtime/base/object_helper.cpp index 22eec2ae4..c9f2572e5 100644 --- a/runtime/base/object_helper.cpp +++ b/runtime/base/object_helper.cpp @@ -89,7 +89,7 @@ JSTaggedValue ObjectHelper::AddEntriesFromIterable(JSThread *thread, const JSHan return JSIterator::IteratorCloseAndReturn(thread, iter, value); } InternalCallParams *arguments = thread->GetInternalCallParams(); - arguments->MakeArgv(key, value); // 2: key and value pair + arguments->MakeArgv(key, value); // 2: key and value pair // Let status be Call(adder, target, «nextValue.[[value]]»). JSTaggedValue ret = JSFunction::Call(thread, adder, JSHandle(target), 2U, arguments->GetArgv()); diff --git a/runtime/base/string_helper.cpp b/runtime/base/string_helper.cpp index 8640b5c13..8b32a7701 100644 --- a/runtime/base/string_helper.cpp +++ b/runtime/base/string_helper.cpp @@ -70,23 +70,23 @@ EcmaString *StringHelper::Trim(JSThread *thread, const std::u16string &thisStr, std::wstring wstr = StringToWstring(str); std::wregex r; if (kind == TrimKind::TRIM_START) { - r = ( - L"^[" - L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" - L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+"); + r = + (L"^[" + L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" + L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+"); } else if (kind == TrimKind::TRIM_END) { - r = ( - L"[" - L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" - L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$"); + r = + (L"[" + L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" + L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$"); } else { ASSERT(kind == TrimKind::TRIM_START_END); - r = ( - L"^[" - L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" - L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+|[" - L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" - L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$"); + r = + (L"^[" + L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" + L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+|[" + L"\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007" + L"\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$"); } wstr = regex_replace(wstr, r, L""); str = WstringToString(wstr); diff --git a/runtime/base/string_helper.h b/runtime/base/string_helper.h index 96c31b62c..ae8937aed 100644 --- a/runtime/base/string_helper.h +++ b/runtime/base/string_helper.h @@ -52,8 +52,7 @@ public: return (index != CString::npos); } - static inline CString RepalceAll(CString str, const CString &oldValue, - const CString &newValue) + static inline CString RepalceAll(CString str, const CString &oldValue, const CString &newValue) { if (oldValue.empty() || oldValue == newValue) { return str; @@ -68,8 +67,8 @@ public: static inline std::string SubString(const JSHandle &string, uint32_t start, uint32_t length) { - return std::string(ConvertToString(string.GetObject(), start, length, - StringConvertedUsage::LOGICOPERATION)); + return std::string( + ConvertToString(string.GetObject(), start, length, StringConvertedUsage::LOGICOPERATION)); } static inline std::u16string Utf16ToU16String(const uint16_t *utf16Data, uint32_t dataLen) @@ -90,28 +89,28 @@ public: { auto *charData = reinterpret_cast(utf8Data); std::string str(charData, dataLen); - std::u16string u16str = std::wstring_convert, char16_t>{}.from_bytes(str); + std::u16string u16str = std::wstring_convert, char16_t> {}.from_bytes(str); return u16str; } static inline std::string WstringToString(const std::wstring &wstr) { - return std::wstring_convert, wchar_t>{}.to_bytes(wstr); + return std::wstring_convert, wchar_t> {}.to_bytes(wstr); } static inline std::wstring StringToWstring(const std::string &str) { - return std::wstring_convert, wchar_t>{}.from_bytes(str); + return std::wstring_convert, wchar_t> {}.from_bytes(str); } static inline std::string U16stringToString(const std::u16string &u16str) { - return std::wstring_convert, char16_t>{}.to_bytes(u16str); + return std::wstring_convert, char16_t> {}.to_bytes(u16str); } static inline std::u16string StringToU16string(const std::string &str) { - return std::wstring_convert, char16_t>{}.from_bytes(str); + return std::wstring_convert, char16_t> {}.from_bytes(str); } static inline size_t Find(const std::string &thisStr, const std::string &searchStr, int32_t pos) @@ -186,7 +185,7 @@ public: static inline uint32_t Utf8ToU32String(const std::vector &data) { std::string str(data.begin(), data.end()); - std::u32string u32str = std::wstring_convert, char32_t>{}.from_bytes(str); + std::u32string u32str = std::wstring_convert, char32_t> {}.from_bytes(str); auto u32data = reinterpret_cast(u32str.data()); return *u32data; } diff --git a/runtime/base/utf_helper.cpp b/runtime/base/utf_helper.cpp index a287adc62..e033f8876 100644 --- a/runtime/base/utf_helper.cpp +++ b/runtime/base/utf_helper.cpp @@ -163,7 +163,7 @@ size_t ConvertRegionUtf16ToUtf8(const uint16_t *utf16In, uint8_t *utf8Out, size_ uint16_t next16Code = 0; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if ((i + 1) != end && utf::IsAvailableNextUtf16Code(utf16In[i + 1])) { - next16Code = utf16In[i + 1]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + next16Code = utf16In[i + 1]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) Utf8Char ch = ConvertUtf16ToUtf8(utf16In[i], next16Code, modify); diff --git a/runtime/builtins.cpp b/runtime/builtins.cpp index 123b8456d..1fb9de530 100644 --- a/runtime/builtins.cpp +++ b/runtime/builtins.cpp @@ -2536,9 +2536,8 @@ void Builtins::InitializeAsyncGeneratorFunction(const JSHandle &env, // 26.3.3.1 AsyncGeneratorFunction.prototype.constructor // AsyncGeneratorFunction.prototype_or_dynclass - JSHandle asyncGeneratorFuncInstanceDynclass = - factory_->NewEcmaDynClass(JSFunction::SIZE, JSType::JS_ASYNC_GENERATOR_FUNCTION, - asyncGeneratorFuncPrototypeValue, HClass::IS_CALLABLE); + JSHandle asyncGeneratorFuncInstanceDynclass = factory_->NewEcmaDynClass( + JSFunction::SIZE, JSType::JS_ASYNC_GENERATOR_FUNCTION, asyncGeneratorFuncPrototypeValue, HClass::IS_CALLABLE); asyncGeneratorFuncInstanceDynclass->SetExtensible(true); asyncGeneratorFuncInstanceDynclass->GetHClass()->MarkFieldAsNative(JSFunction::METHOD_OFFSET); diff --git a/runtime/builtins/builtins_async_generator.cpp b/runtime/builtins/builtins_async_generator.cpp index 1703e85cd..9723b7491 100644 --- a/runtime/builtins/builtins_async_generator.cpp +++ b/runtime/builtins/builtins_async_generator.cpp @@ -29,8 +29,7 @@ JSTaggedValue BuiltinsAsyncGenerator::AsyncGeneratorPrototypeNext(EcmaRuntimeCal // 2. Let completion be NormalCompletion(value). JSHandle value = GetCallArg(argv, 0); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle completionRecord = - factory->NewCompletionRecord(CompletionRecord::NORMAL, value); + JSHandle completionRecord = factory->NewCompletionRecord(CompletionRecord::NORMAL, value); // 3. Return ! AsyncGeneratorEnqueue(generator, completion, empty). JSHandle result = JSAsyncGeneratorObject::AsyncGeneratorEnqueue(thread, generator, completionRecord); @@ -50,8 +49,7 @@ JSTaggedValue BuiltinsAsyncGenerator::AsyncGeneratorPrototypeReturn(EcmaRuntimeC // 2. Let completion be Completion { [[Type]]: return, [[Value]]: value, [[Target]]: empty }. JSHandle value = GetCallArg(argv, 0); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle completionRecord = - factory->NewCompletionRecord(CompletionRecord::RETURN, value); + JSHandle completionRecord = factory->NewCompletionRecord(CompletionRecord::RETURN, value); // 3. Return ! AsyncGeneratorEnqueue(generator, completion, empty). JSHandle result = JSAsyncGeneratorObject::AsyncGeneratorEnqueue(thread, generator, completionRecord); @@ -72,8 +70,7 @@ JSTaggedValue BuiltinsAsyncGenerator::AsyncGeneratorPrototypeThrow(EcmaRuntimeCa // 2. Let completion be ThrowCompletion(exception). JSHandle value = GetCallArg(argv, 0); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle completionRecord = - factory->NewCompletionRecord(CompletionRecord::THROW, value); + JSHandle completionRecord = factory->NewCompletionRecord(CompletionRecord::THROW, value); // 3. Return ! AsyncGeneratorEnqueue(generator, completion, empty). JSHandle result = JSAsyncGeneratorObject::AsyncGeneratorEnqueue(thread, generator, completionRecord); diff --git a/runtime/builtins/builtins_generator.cpp b/runtime/builtins/builtins_generator.cpp index f20a2c3e1..5cbcce390 100644 --- a/runtime/builtins/builtins_generator.cpp +++ b/runtime/builtins/builtins_generator.cpp @@ -63,8 +63,7 @@ JSTaggedValue BuiltinsGenerator::GeneratorPrototypeReturn(EcmaRuntimeCallInfo *a // 2.Let C be Completion { [[Type]]: return, [[Value]]: value, [[Target]]: empty }. JSHandle value = GetCallArg(argv, 0); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle completionRecord = - factory->NewCompletionRecord(CompletionRecord::RETURN, value); + JSHandle completionRecord = factory->NewCompletionRecord(CompletionRecord::RETURN, value); // 3.Return ? GeneratorResumeAbrupt(g, C). JSHandle result = JSGeneratorObject::GeneratorResumeAbrupt(thread, generator, completionRecord); @@ -88,8 +87,7 @@ JSTaggedValue BuiltinsGenerator::GeneratorPrototypeThrow(EcmaRuntimeCallInfo *ar // 2.Let C be ThrowCompletion(exception). JSHandle exception = GetCallArg(argv, 0); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); - JSHandle completionRecord = - factory->NewCompletionRecord(CompletionRecord::THROW, exception); + JSHandle completionRecord = factory->NewCompletionRecord(CompletionRecord::THROW, exception); // 3.Return ? GeneratorResumeAbrupt(g, C). JSHandle result = JSGeneratorObject::GeneratorResumeAbrupt(thread, generator, completionRecord); diff --git a/runtime/builtins/builtins_global.cpp b/runtime/builtins/builtins_global.cpp index 7fec05da9..9286d8e5a 100644 --- a/runtime/builtins/builtins_global.cpp +++ b/runtime/builtins/builtins_global.cpp @@ -448,8 +448,7 @@ JSTaggedValue BuiltinsGlobal::Decode(JSThread *thread, const JSHandle(&vv), 1); } else { - sStr = - StringHelper::StringToU16string(StringHelper::SubString(str, start, k - start + 1)); + sStr = StringHelper::StringToU16string(StringHelper::SubString(str, start, k - start + 1)); } } else { uint16_t lv = (((vv - ecmascript::base::utf_helper::DECODE_SECOND_FACTOR) & BIT16_MASK) + diff --git a/runtime/builtins/builtins_math.cpp b/runtime/builtins/builtins_math.cpp index b6a5b175b..1cd3f1878 100644 --- a/runtime/builtins/builtins_math.cpp +++ b/runtime/builtins/builtins_math.cpp @@ -472,7 +472,8 @@ JSTaggedValue BuiltinsMath::Log2(EcmaRuntimeCallInfo *argv) inline bool IsNegZero(double value) { - return (value == 0.0 && (bit_cast(value) & ecmascript::base::DOUBLE_SIGN_MASK) == ecmascript::base::DOUBLE_SIGN_MASK); + return (value == 0.0 && + (bit_cast(value) & ecmascript::base::DOUBLE_SIGN_MASK) == ecmascript::base::DOUBLE_SIGN_MASK); } // 20.2.2.24 diff --git a/runtime/builtins/builtins_number.cpp b/runtime/builtins/builtins_number.cpp index 0c7657dba..8fbef396a 100644 --- a/runtime/builtins/builtins_number.cpp +++ b/runtime/builtins/builtins_number.cpp @@ -164,10 +164,11 @@ JSTaggedValue BuiltinsNumber::ParseFloat(EcmaRuntimeCallInfo *argv) RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (UNLIKELY(numberString->IsUtf16())) { - size_t len = ecmascript::base::utf_helper::Utf16ToUtf8Size(numberString->GetDataUtf16(), numberString->GetLength()) - 1; + size_t len = + ecmascript::base::utf_helper::Utf16ToUtf8Size(numberString->GetDataUtf16(), numberString->GetLength()) - 1; CVector buf(len); len = ecmascript::base::utf_helper::ConvertRegionUtf16ToUtf8(numberString->GetDataUtf16(), buf.data(), - numberString->GetLength(), len, 0); + numberString->GetLength(), len, 0); auto str = Span(buf.data(), len); return ParseFloatStr(str); } @@ -203,10 +204,11 @@ JSTaggedValue BuiltinsNumber::ParseInt(EcmaRuntimeCallInfo *argv) RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (UNLIKELY(numberString->IsUtf16())) { - size_t len = ecmascript::base::utf_helper::Utf16ToUtf8Size(numberString->GetDataUtf16(), numberString->GetLength()) - 1; + size_t len = + ecmascript::base::utf_helper::Utf16ToUtf8Size(numberString->GetDataUtf16(), numberString->GetLength()) - 1; CVector buf(len); len = ecmascript::base::utf_helper::ConvertRegionUtf16ToUtf8(numberString->GetDataUtf16(), buf.data(), - numberString->GetLength(), len, 0); + numberString->GetLength(), len, 0); auto str = Span(buf.data(), len); return ParseIntStr(str, radix); } diff --git a/runtime/builtins/builtins_regexp.cpp b/runtime/builtins/builtins_regexp.cpp index 4698b4f80..eedeba4aa 100644 --- a/runtime/builtins/builtins_regexp.cpp +++ b/runtime/builtins/builtins_regexp.cpp @@ -1105,8 +1105,8 @@ JSTaggedValue BuiltinsRegExp::Split(EcmaRuntimeCallInfo *argv) // iv. Else e != p, // 1. Let T be a String value equal to the substring of S consisting of the elements at indices p // (inclusive) through q (exclusive). - std::string stdStrT = ecmascript::base::StringHelper::SubString( - JSHandle::Cast(jsString), startIndex, (endIndex - startIndex)); + std::string stdStrT = ecmascript::base::StringHelper::SubString(JSHandle::Cast(jsString), + startIndex, (endIndex - startIndex)); // 2. Assert: The following call will never result in an abrupt completion. // 3. Perform CreateDataProperty(A, ToString(lengthA), T). JSHandle tValue(factory->NewFromStdString(stdStrT)); @@ -1165,8 +1165,8 @@ JSTaggedValue BuiltinsRegExp::Split(EcmaRuntimeCallInfo *argv) } // 25. Let T be a String value equal to the substring of S consisting of the elements at indices p (inclusive) // through size (exclusive). - std::string stdStrT = ecmascript::base::StringHelper::SubString(JSHandle::Cast(jsString), - startIndex, (size - startIndex)); + std::string stdStrT = ecmascript::base::StringHelper::SubString(JSHandle::Cast(jsString), startIndex, + (size - startIndex)); // 26. Assert: The following call will never result in an abrupt completion. // 27. Perform CreateDataProperty(A, ToString(lengthA), t). JSHandle tValue(factory->NewFromStdString(stdStrT)); diff --git a/runtime/builtins/builtins_string_iterator.cpp b/runtime/builtins/builtins_string_iterator.cpp index 1eecb7082..e90ff858a 100644 --- a/runtime/builtins/builtins_string_iterator.cpp +++ b/runtime/builtins/builtins_string_iterator.cpp @@ -75,7 +75,8 @@ JSTaggedValue BuiltinsStringIterator::Next(EcmaRuntimeCallInfo *argv) // first. // c. Else, let resultString be the string consisting of the code unit first followed by the code unit second. uint16_t second = string.GetObject()->At(position + 1); - if (second < ecmascript::base::utf_helper::DECODE_TRAIL_LOW || second > ecmascript::base::utf_helper::DECODE_TRAIL_HIGH) { + if (second < ecmascript::base::utf_helper::DECODE_TRAIL_LOW || + second > ecmascript::base::utf_helper::DECODE_TRAIL_HIGH) { std::vector resultString {first, 0x0}; result.Update(factory->NewFromUtf16UnCheck(resultString.data(), 1, false).GetTaggedValue()); } else { diff --git a/runtime/builtins/builtins_typedarray.cpp b/runtime/builtins/builtins_typedarray.cpp index 8e8a93df6..113ef39e5 100644 --- a/runtime/builtins/builtins_typedarray.cpp +++ b/runtime/builtins/builtins_typedarray.cpp @@ -704,13 +704,13 @@ JSTaggedValue BuiltinsTypedArray::Includes(EcmaRuntimeCallInfo *argv) // 6. If n is positiveInfinity, return false. if (JSTaggedValue::Equal(thread, msg1, - JSHandle(thread, JSTaggedValue(base::POSITIVE_INFINITY)))) { + JSHandle(thread, JSTaggedValue(base::POSITIVE_INFINITY)))) { return GetTaggedBoolean(false); } // 7. Else if n is negativeInfinity, set n to 0. if (JSTaggedValue::Equal(thread, msg1, - JSHandle(thread, JSTaggedValue(-base::POSITIVE_INFINITY)))) { + JSHandle(thread, JSTaggedValue(-base::POSITIVE_INFINITY)))) { fromIndex = 0; } } diff --git a/runtime/builtins/builtins_weak_map.cpp b/runtime/builtins/builtins_weak_map.cpp index 7ce6649e4..720750c7f 100644 --- a/runtime/builtins/builtins_weak_map.cpp +++ b/runtime/builtins/builtins_weak_map.cpp @@ -112,8 +112,8 @@ JSTaggedValue BuiltinsWeakMap::WeakMapConstructor(EcmaRuntimeCallInfo *argv) // Let status be Call(adder, weakMap, «nextValue.[[value]]»). InternalCallParams *arguments = thread->GetInternalCallParams(); arguments->MakeArgv(key, value); - JSTaggedValue ret = JSFunction::Call(thread, - adder, JSHandle(weakMap), 2, arguments->GetArgv()); // 2: key and value pair + JSTaggedValue ret = JSFunction::Call(thread, adder, JSHandle(weakMap), 2, + arguments->GetArgv()); // 2: key and value pair status.Update(ret); // If status is an abrupt completion, return IteratorClose(iter, status). diff --git a/runtime/class_info_extractor.h b/runtime/class_info_extractor.h index 723212798..2420f4a0f 100644 --- a/runtime/class_info_extractor.h +++ b/runtime/class_info_extractor.h @@ -94,9 +94,8 @@ public: private: static bool ExtractAndReturnWhetherWithElements(JSThread *thread, const JSHandle &literal, - const ExtractContentsDetail &detail, - JSHandle &keys, JSHandle &properties, - JSHandle &elements); + const ExtractContentsDetail &detail, JSHandle &keys, + JSHandle &properties, JSHandle &elements); static JSHandle CreatePrototypeHClass(JSThread *thread, JSHandle &keys, JSHandle &properties); diff --git a/runtime/common.h b/runtime/common.h index e663f65e1..d6b0677a8 100644 --- a/runtime/common.h +++ b/runtime/common.h @@ -32,7 +32,7 @@ constexpr size_t NUM_MANDATORY_JSFUNC_ARGS = 3; #define DUMP_API_ATTR __attribute__((unused)) #else // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define DUMP_API_ATTR __attribute__((visibility ("default"), used)) +#define DUMP_API_ATTR __attribute__((visibility("default"), used)) #endif } // namespace ecmascript } // namespace panda diff --git a/runtime/containers/containers_private.h b/runtime/containers/containers_private.h index 55cfdc988..705dc53e5 100644 --- a/runtime/containers/containers_private.h +++ b/runtime/containers/containers_private.h @@ -53,15 +53,14 @@ private: int length); static void SetFrozenConstructor(JSThread *thread, const JSHandle &obj, const char *keyChar, JSHandle &value); - static JSHandle CreateGetter(JSThread *thread, EcmaEntrypoint func, const char *name, - int length); - static void SetGetter(JSThread *thread, const JSHandle &obj, - const JSHandle &key, const JSHandle &getter); - static void SetFunctionAtSymbol(JSThread *thread, const JSHandle &env, - const JSHandle &obj, const JSHandle &symbol, - const char *name, EcmaEntrypoint func, int length); - static void SetStringTagSymbol(JSThread *thread, const JSHandle &env, - const JSHandle &obj, const char *key); + static JSHandle CreateGetter(JSThread *thread, EcmaEntrypoint func, const char *name, int length); + static void SetGetter(JSThread *thread, const JSHandle &obj, const JSHandle &key, + const JSHandle &getter); + static void SetFunctionAtSymbol(JSThread *thread, const JSHandle &env, const JSHandle &obj, + const JSHandle &symbol, const char *name, EcmaEntrypoint func, + int length); + static void SetStringTagSymbol(JSThread *thread, const JSHandle &env, const JSHandle &obj, + const char *key); static JSHandle InitializeArrayList(JSThread *thread); }; } // namespace panda::ecmascript::containers diff --git a/runtime/ecma_class_linker_extension.cpp b/runtime/ecma_class_linker_extension.cpp index 68ea4536b..768bc9f38 100644 --- a/runtime/ecma_class_linker_extension.cpp +++ b/runtime/ecma_class_linker_extension.cpp @@ -114,10 +114,9 @@ Class *EcmaClassLinkerExtension::NewClass(const uint8_t *descriptor, size_t vtab hclass_ptr->SetClass(hclass_ptr); JSHandle klass_obj(vm_->GetJSThread(), factory->NewNonMovableDynObject(hclass)); - auto *klass = reinterpret_cast( - ToUintPtr(klass_obj.GetObject()) + ObjectHeader::ObjectHeaderSize()); - new (klass) - Class(descriptor, panda_file::SourceLang::ECMASCRIPT, vtableSize, imtSize, class_size); + auto *klass = + reinterpret_cast(ToUintPtr(klass_obj.GetObject()) + ObjectHeader::ObjectHeaderSize()); + new (klass) Class(descriptor, panda_file::SourceLang::ECMASCRIPT, vtableSize, imtSize, class_size); klass->SetManagedObject(klass_obj.GetObject()); AddCreatedClass(klass); return klass; diff --git a/runtime/ecma_class_linker_extension.h b/runtime/ecma_class_linker_extension.h index aee9dcac8..5252357fe 100644 --- a/runtime/ecma_class_linker_extension.h +++ b/runtime/ecma_class_linker_extension.h @@ -101,7 +101,7 @@ private: bool InitializeImpl(bool cmpStrEnabled) override; Class *NewClass(const uint8_t *descriptor, size_t vtableSize, size_t imtSize, size_t size); - EcmaVM *vm_{nullptr}; + EcmaVM *vm_ {nullptr}; }; } // namespace ecmascript } // namespace panda diff --git a/runtime/ecma_global_storage.h b/runtime/ecma_global_storage.h index 3a5bd39b7..46c9354a0 100644 --- a/runtime/ecma_global_storage.h +++ b/runtime/ecma_global_storage.h @@ -191,7 +191,7 @@ public: return freePrev_; } - template + template inline void IterateUsageGlobal(Callback callback) { Node *next = usedList_; @@ -204,13 +204,13 @@ public: } } - DEFAULT_MOVE_SEMANTIC(NodeList); - DEFAULT_COPY_SEMANTIC(NodeList); + DEFAULT_MOVE_SEMANTIC(NodeList); + DEFAULT_COPY_SEMANTIC(NodeList); private: std::array nodeList_; // all - Node *freeList_ {nullptr}; // dispose node - Node *usedList_ {nullptr}; // usage node + Node *freeList_ {nullptr}; // dispose node + Node *usedList_ {nullptr}; // usage node int32_t index_ {0}; bool isWeak_ {false}; NodeList *next_ {nullptr}; @@ -224,7 +224,7 @@ public: inline uintptr_t SetWeak(uintptr_t addr); inline bool IsWeak(uintptr_t addr) const; - template + template void IterateUsageGlobal(Callback callback) { NodeList *next = topGlobalNodes_; @@ -237,7 +237,7 @@ public: } } - template + template void IterateWeakUsageGlobal(Callback callback) { NodeList *next = topWeakGlobalNodes_; diff --git a/runtime/ecma_handle_scope-inl.h b/runtime/ecma_handle_scope-inl.h index a1c3c3620..d183a49fa 100644 --- a/runtime/ecma_handle_scope-inl.h +++ b/runtime/ecma_handle_scope-inl.h @@ -21,7 +21,9 @@ namespace panda::ecmascript { inline EcmaHandleScope::EcmaHandleScope(JSThread *thread) - : thread_(thread), prevNext_(thread->handleScopeStorageNext_), prevEnd_(thread->handleScopeStorageEnd_), + : thread_(thread), + prevNext_(thread->handleScopeStorageNext_), + prevEnd_(thread->handleScopeStorageEnd_), prevHandleStorageIndex_(thread->currentHandleStorageIndex_) { thread->HandleScopeCountAdd(); diff --git a/runtime/ecma_handle_scope.h b/runtime/ecma_handle_scope.h index a7e934c13..1709fc7c1 100644 --- a/runtime/ecma_handle_scope.h +++ b/runtime/ecma_handle_scope.h @@ -42,7 +42,7 @@ private: JSThread *thread_; JSTaggedType *prevNext_; JSTaggedType *prevEnd_; - int prevHandleStorageIndex_{-1}; + int prevHandleStorageIndex_ {-1}; NO_COPY_SEMANTIC(EcmaHandleScope); NO_MOVE_SEMANTIC(EcmaHandleScope); diff --git a/runtime/ecma_macros.h b/runtime/ecma_macros.h index 340bfd9c9..a92a7b37f 100644 --- a/runtime/ecma_macros.h +++ b/runtime/ecma_macros.h @@ -63,7 +63,7 @@ static inline void UnalignedStore(T *p, T v) #define GET_VALUE(addr, offset) Barriers::GetDynValue((addr), (offset)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define SET_VALUE_WITH_BARRIER(thread, addr, offset, value) \ +#define SET_VALUE_WITH_BARRIER(thread, addr, offset, value) \ ObjectAccessor::SetDynValue(thread, addr, offset, value.GetRawData()) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/runtime/ecma_module.cpp b/runtime/ecma_module.cpp index b206ae56f..96790105b 100644 --- a/runtime/ecma_module.cpp +++ b/runtime/ecma_module.cpp @@ -241,11 +241,7 @@ void ModuleManager::CopyModule(const JSThread *thread, JSHandle s void ModuleManager::DebugPrint([[maybe_unused]] const JSThread *thread, [[maybe_unused]] const CString &caller) { std::cout << "ModuleStack:"; - for_each(moduleNames_.cbegin(), - moduleNames_.cend(), - [](const CString& s)->void { - std::cout << s << " "; - }); + for_each(moduleNames_.cbegin(), moduleNames_.cend(), [](const CString &s) -> void { std::cout << s << " "; }); std::cout << "\n"; } } // namespace panda::ecmascript diff --git a/runtime/ecma_module.h b/runtime/ecma_module.h index 78051b1b5..440181eec 100644 --- a/runtime/ecma_module.h +++ b/runtime/ecma_module.h @@ -34,7 +34,7 @@ public: JSHandle GetItem(const JSThread *thread, JSHandle itemName); static void AddItem(const JSThread *thread, JSHandle module, JSHandle itemName, - JSHandle itemValue); + JSHandle itemValue); static void RemoveItem(const JSThread *thread, JSHandle module, JSHandle itemName); @@ -50,7 +50,7 @@ public: protected: static void CopyModuleInternal(const JSThread *thread, JSHandle dstModule, - JSHandle srcModule); + JSHandle srcModule); friend class ModuleManager; }; @@ -91,7 +91,7 @@ private: NO_COPY_SEMANTIC(ModuleManager); NO_MOVE_SEMANTIC(ModuleManager); - EcmaVM *vm_{nullptr}; + EcmaVM *vm_ {nullptr}; JSTaggedValue ecmaModules_ {JSTaggedValue::Hole()}; std::vector moduleNames_ {DEAULT_DICTIONART_CAPACITY}; diff --git a/runtime/ecma_string-inl.h b/runtime/ecma_string-inl.h index af630fe8d..cc4921026 100644 --- a/runtime/ecma_string-inl.h +++ b/runtime/ecma_string-inl.h @@ -97,7 +97,7 @@ inline EcmaString *EcmaString::CreateFromUtf16(const uint16_t *utf16Data, uint32 return string; } -template +template inline uint16_t EcmaString::At(int32_t index) const { int32_t length = GetLength(); diff --git a/runtime/ecma_string.h b/runtime/ecma_string.h index 3d092a85a..8ef74a513 100644 --- a/runtime/ecma_string.h +++ b/runtime/ecma_string.h @@ -27,11 +27,11 @@ namespace panda { namespace ecmascript { -template +template class JSHandle; class EcmaVM; -template +template static int32_t ComputeHashForData(const T *data, size_t size) { uint32_t hash = 0; @@ -69,7 +69,7 @@ public: STRING_UNCOMPRESSED, }; - template + template uint16_t At(int32_t index) const; int32_t Compare(const EcmaString *rhs) const; @@ -323,19 +323,19 @@ private: static bool IsUtf8EqualsUtf16(const uint8_t *utf8Data, size_t utf8Len, const uint16_t *utf16Data, uint32_t utf16Len); - template + template /** * Check that two spans are equal. Should have the same length. */ static bool StringsAreEquals(Span &str1, Span &str2); - template + template /** * Copy String from src to dst * */ static bool StringCopy(Span &dst, size_t dstMax, Span &src, size_t count); - template + template static int32_t IndexOf(Span &lhsSp, Span &rhsSp, int32_t pos, int32_t max); }; } // namespace ecmascript diff --git a/runtime/ecma_string_table.cpp b/runtime/ecma_string_table.cpp index c60e203d2..27d948f01 100644 --- a/runtime/ecma_string_table.cpp +++ b/runtime/ecma_string_table.cpp @@ -158,7 +158,8 @@ void EcmaStringTable::Sweep(const GCObjectVisitor &visitor) } } -bool EcmaStringTable::UpdateMoved() { +bool EcmaStringTable::UpdateMoved() +{ bool updated = false; os::memory::WriteLockHolder holder(table_lock_); for (auto it = table_.begin(); it != table_.end();) { diff --git a/runtime/ecma_string_table.h b/runtime/ecma_string_table.h index a0d6ae212..a60977a87 100644 --- a/runtime/ecma_string_table.h +++ b/runtime/ecma_string_table.h @@ -69,7 +69,7 @@ private: CUnorderedMultiMap table_ GUARDED_BY(table_lock_); mutable os::memory::RWLock table_lock_; - const EcmaVM *vm_{nullptr}; + const EcmaVM *vm_ {nullptr}; friend class SnapShotSerialize; }; } // namespace panda::ecmascript diff --git a/runtime/global_dictionary-inl.h b/runtime/global_dictionary-inl.h index b5e418457..5d9d2a166 100644 --- a/runtime/global_dictionary-inl.h +++ b/runtime/global_dictionary-inl.h @@ -118,8 +118,7 @@ void GlobalDictionary::GetAllKeys(const JSThread *thread, int offset, TaggedArra } } -void GlobalDictionary::GetEnumAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray, - uint32_t *keys) const +void GlobalDictionary::GetEnumAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray, uint32_t *keys) const { ASSERT_PRINT(offset + EntriesCount() <= static_cast(keyArray->GetLength()), "keyArray capacity is not enough for dictionary"); diff --git a/runtime/global_env_constants.h b/runtime/global_env_constants.h index d4c192c6f..f06d29aba 100644 --- a/runtime/global_env_constants.h +++ b/runtime/global_env_constants.h @@ -24,7 +24,7 @@ namespace panda::ecmascript { // Forward Declaration class ObjectFactory; -template +template class JSHandle; class JSHClass; class JSThread; @@ -122,7 +122,7 @@ class JSThread; V(JSTaggedValue, ObjectString, OBJECT_STRING_INDEX, object) \ V(JSTaggedValue, TrueString, TRUE_STRING_INDEX, true) \ V(JSTaggedValue, FalseString, FALSE_STRING_INDEX, false) \ - V(JSTaggedValue, ReturnString, RETURN_STRING_INDEX, return) \ + V(JSTaggedValue, ReturnString, RETURN_STRING_INDEX, return ) \ V(JSTaggedValue, ThrowString, THROW_STRING_INDEX, throw) \ V(JSTaggedValue, ProxyConstructString, PROXY_CONSTRUCT_STRING_INDEX, construct) \ V(JSTaggedValue, ProxyCallString, PROXY_CALL_STRING_INDEX, call) \ diff --git a/runtime/global_handle_collection.h b/runtime/global_handle_collection.h index d7557b133..f87d88311 100644 --- a/runtime/global_handle_collection.h +++ b/runtime/global_handle_collection.h @@ -19,7 +19,7 @@ #include "plugins/ecmascript/runtime/js_thread.h" namespace panda::ecmascript { -template +template class JSHandle; class GlobalHandleCollection { public: @@ -30,21 +30,21 @@ public: DEFAULT_MOVE_SEMANTIC(GlobalHandleCollection); DEFAULT_COPY_SEMANTIC(GlobalHandleCollection); - template + template JSHandle NewHandle(JSTaggedType value) { uintptr_t addr = thread_->GetEcmaGlobalStorage()->NewGlobalHandle(value); return JSHandle(addr); } - template + template void Dispose(JSHandle handle) { thread_->GetEcmaGlobalStorage()->DisposeGlobalHandle(handle.GetAddress()); } private: - JSThread *thread_{nullptr}; + JSThread *thread_ {nullptr}; }; } // namespace panda::ecmascript diff --git a/runtime/hprof/heap_profiler.h b/runtime/hprof/heap_profiler.h index 0efef6266..4395cb514 100644 --- a/runtime/hprof/heap_profiler.h +++ b/runtime/hprof/heap_profiler.h @@ -68,7 +68,7 @@ private: const size_t MAX_NUM_HPROF = 5; // ~10MB CVector hprofs_; - HeapSnapShotJSONSerializer *jsonSerializer_{nullptr}; + HeapSnapShotJSONSerializer *jsonSerializer_ {nullptr}; std::unique_ptr heapTracker_; const Heap *heap_; }; diff --git a/runtime/hprof/heap_profiler_interface.cpp b/runtime/hprof/heap_profiler_interface.cpp index 24011bc90..9cb907f0f 100644 --- a/runtime/hprof/heap_profiler_interface.cpp +++ b/runtime/hprof/heap_profiler_interface.cpp @@ -27,8 +27,8 @@ HeapProfilerInterface *HeapProfilerInterface::GetInstance(JSThread *thread) return HeapProfilerInterface::heapProfile_; } -void HeapProfilerInterface::DumpHeapSnapShot(JSThread *thread, DumpFormat dumpFormat, - const std::string &filePath, bool isVmMode) +void HeapProfilerInterface::DumpHeapSnapShot(JSThread *thread, DumpFormat dumpFormat, const std::string &filePath, + bool isVmMode) { LOG(ERROR, RUNTIME) << "HeapProfilerInterface::DumpHeapSnapshot"; const Heap *heap = thread->GetEcmaVM()->GetHeap(); diff --git a/runtime/hprof/heap_profiler_interface.h b/runtime/hprof/heap_profiler_interface.h index 08436af57..a338c65fc 100644 --- a/runtime/hprof/heap_profiler_interface.h +++ b/runtime/hprof/heap_profiler_interface.h @@ -25,8 +25,8 @@ enum class DumpFormat { JSON, BINARY, OTHER }; class HeapProfilerInterface { public: static HeapProfilerInterface *GetInstance(JSThread *thread); - static void DumpHeapSnapShot(JSThread *thread, DumpFormat dumpFormat, - const std::string &filePath, bool isVmMode = true); + static void DumpHeapSnapShot(JSThread *thread, DumpFormat dumpFormat, const std::string &filePath, + bool isVmMode = true); static HeapProfilerInterface *CreateHeapProfiler(JSThread *thread); static void Destroy(JSThread *thread, HeapProfilerInterface *heapProfiler); @@ -40,6 +40,7 @@ public: NO_MOVE_SEMANTIC(HeapProfilerInterface); NO_COPY_SEMANTIC(HeapProfilerInterface); + private: static HeapProfilerInterface *heapProfile_; }; diff --git a/runtime/hprof/heap_snapshot_json_serializer.cpp b/runtime/hprof/heap_snapshot_json_serializer.cpp index 93d50aa05..a811dd627 100644 --- a/runtime/hprof/heap_snapshot_json_serializer.cpp +++ b/runtime/hprof/heap_snapshot_json_serializer.cpp @@ -38,7 +38,7 @@ bool HeapSnapShotJSONSerializer::Serialize(HeapSnapShot *snapShot, const CString SerializeStringTable(); // 8. SerializerSnapShotClosure(); // 9. - WriteJSON(fileName); // 10. + WriteJSON(fileName); // 10. LOG(ERROR, RUNTIME) << "HeapSnapShotJSONSerializer::Serialize exit"; return true; } @@ -123,7 +123,7 @@ void HeapSnapShotJSONSerializer::SerializeEdges() if (i == edges->size() - 1) { // add comma at last the line stringBuffer_ << edge->GetTo()->GetIndex() * Node::NODE_FIELD_COUNT << "],\n"; // 3. } else { - stringBuffer_ << edge->GetTo()->GetIndex() * Node::NODE_FIELD_COUNT << "\n"; // 3. + stringBuffer_ << edge->GetTo()->GetIndex() * Node::NODE_FIELD_COUNT << "\n"; // 3. } i++; } diff --git a/runtime/hprof/heap_snapshot_json_serializer.h b/runtime/hprof/heap_snapshot_json_serializer.h index b23a29f43..84ebf89d3 100644 --- a/runtime/hprof/heap_snapshot_json_serializer.h +++ b/runtime/hprof/heap_snapshot_json_serializer.h @@ -49,7 +49,7 @@ private: void WriteJSON(const CString &fileName); fstream outputStream_; - HeapSnapShot *snapShot_{nullptr}; + HeapSnapShot *snapShot_ {nullptr}; stringstream stringBuffer_; }; } // namespace panda::ecmascript diff --git a/runtime/hprof/string_hashmap.h b/runtime/hprof/string_hashmap.h index b24a9ac4e..776a750d6 100644 --- a/runtime/hprof/string_hashmap.h +++ b/runtime/hprof/string_hashmap.h @@ -75,7 +75,7 @@ private: void Clear(); const Heap *heap_; CVector orderedKey_; // Used for Serialize Order - size_t index_{2}; // 2: Offset the String-Table Header + size_t index_ {2}; // 2: Offset the String-Table Header CUnorderedMap indexMap_; CUnorderedMap hashmap_; }; diff --git a/runtime/ic/ic_binary_op.h b/runtime/ic/ic_binary_op.h index bef23af87..ea41abb0b 100644 --- a/runtime/ic/ic_binary_op.h +++ b/runtime/ic/ic_binary_op.h @@ -33,17 +33,17 @@ enum class BinaryType : uint8_t { class ICBinaryOP { public: static inline JSTaggedValue AddWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, - JSTaggedValue right, JSTaggedValue argType); + JSTaggedValue right, JSTaggedValue argType); static inline JSTaggedValue SubWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, - JSTaggedValue right, JSTaggedValue argType); + JSTaggedValue right, JSTaggedValue argType); static inline JSTaggedValue MulWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, - JSTaggedValue right, JSTaggedValue argType); + JSTaggedValue right, JSTaggedValue argType); static inline JSTaggedValue DivWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, - JSTaggedValue right, JSTaggedValue argType); + JSTaggedValue right, JSTaggedValue argType); static inline JSTaggedValue ModWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, JSTaggedValue right, JSTaggedValue argType); - static inline void GetBitOPDate(JSThread *thread, JSTaggedValue left, JSTaggedValue right, - int32_t &opNumber0, int32_t &opNumber1, BinaryType opType); + static inline void GetBitOPDate(JSThread *thread, JSTaggedValue left, JSTaggedValue right, int32_t &opNumber0, + int32_t &opNumber1, BinaryType opType); static inline JSTaggedValue ShlWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, JSTaggedValue right, JSTaggedValue argType); static inline JSTaggedValue ShrWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, @@ -52,8 +52,8 @@ public: JSTaggedValue right, JSTaggedValue argType); static inline JSTaggedValue AndWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, JSTaggedValue right, JSTaggedValue argType); - static inline JSTaggedValue OrWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, - JSTaggedValue right, JSTaggedValue argType); + static inline JSTaggedValue OrWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, JSTaggedValue right, + JSTaggedValue argType); static inline JSTaggedValue XorWithTSType(JSThread *thread, EcmaVM *ecma_vm, JSTaggedValue left, JSTaggedValue right, JSTaggedValue argType); }; diff --git a/runtime/ic/ic_compare_op.cpp b/runtime/ic/ic_compare_op.cpp index 2ecb230fd..f3db73bf4 100644 --- a/runtime/ic/ic_compare_op.cpp +++ b/runtime/ic/ic_compare_op.cpp @@ -27,8 +27,8 @@ #include "plugins/ecmascript/runtime/runtime_call_id.h" namespace panda::ecmascript { -JSTaggedValue CompareOp::EqualWithIC(JSThread* thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType) +JSTaggedValue CompareOp::EqualWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType) { INTERPRETER_TRACE(thread, EqualWithIC); double leftDouble = 0; @@ -82,20 +82,20 @@ JSTaggedValue CompareOp::EqualWithIC(JSThread* thread, JSTaggedValue left, JSHandle rightPrimitive(thread, JSTaggedValue::ToPrimitive(thread, rightHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::False()); if (rightPrimitive->IsNumber()) { - ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); + ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_NUMBER); } else if (rightPrimitive->IsString()) { - ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_STRING); + ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_STRING); } else if (rightPrimitive->IsBoolean()) { - ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_BOOLEAN); + ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_BOOLEAN); } break; } case CompareOpType::STRING_STRING: { bool result = EcmaString::StringsAreEqual(static_cast(left.GetTaggedObject()), - static_cast(right.GetTaggedObject())); + static_cast(right.GetTaggedObject())); ret = result ? JSTaggedValue::True() : JSTaggedValue::False(); break; } @@ -128,14 +128,14 @@ JSTaggedValue CompareOp::EqualWithIC(JSThread* thread, JSTaggedValue left, JSHandle rightPrimitive(thread, JSTaggedValue::ToPrimitive(thread, rightHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::False()); if (rightPrimitive->IsNumber()) { - ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_STRING); + ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_STRING); } else if (rightPrimitive->IsString()) { - ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::STRING_STRING); + ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::STRING_STRING); } else if (rightPrimitive->IsBoolean()) { - ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + ret = EqualWithIC(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); } break; } @@ -155,14 +155,14 @@ JSTaggedValue CompareOp::EqualWithIC(JSThread* thread, JSTaggedValue left, JSHandle leftPrimitive(thread, JSTaggedValue::ToPrimitive(thread, leftHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::False()); if (leftPrimitive->IsNumber()) { - ret = EqualWithIC(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::NUMBER_BOOLEAN); + ret = EqualWithIC(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::NUMBER_BOOLEAN); } else if (leftPrimitive->IsString()) { - ret = EqualWithIC(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + ret = EqualWithIC(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); } else if (leftPrimitive->IsBoolean()) { - ret = EqualWithIC(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::BOOLEAN_BOOLEAN); + ret = EqualWithIC(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::BOOLEAN_BOOLEAN); } break; } @@ -172,14 +172,14 @@ JSTaggedValue CompareOp::EqualWithIC(JSThread* thread, JSTaggedValue left, JSHandle rightPrimitive(thread, JSTaggedValue::ToPrimitive(thread, rightHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::False()); if (rightPrimitive->IsNumber()) { - ret = EqualWithIC(thread, rightPrimitive.GetTaggedValue(), - leftHandle.GetTaggedValue(), CompareOpType::NUMBER_BOOLEAN); + ret = EqualWithIC(thread, rightPrimitive.GetTaggedValue(), leftHandle.GetTaggedValue(), + CompareOpType::NUMBER_BOOLEAN); } else if (rightPrimitive->IsString()) { - ret = EqualWithIC(thread, rightPrimitive.GetTaggedValue(), - leftHandle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + ret = EqualWithIC(thread, rightPrimitive.GetTaggedValue(), leftHandle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); } else if (rightPrimitive->IsBoolean()) { - ret = EqualWithIC(thread, rightPrimitive.GetTaggedValue(), - leftHandle.GetTaggedValue(), CompareOpType::BOOLEAN_BOOLEAN); + ret = EqualWithIC(thread, rightPrimitive.GetTaggedValue(), leftHandle.GetTaggedValue(), + CompareOpType::BOOLEAN_BOOLEAN); } break; } @@ -190,7 +190,7 @@ JSTaggedValue CompareOp::EqualWithIC(JSThread* thread, JSTaggedValue left, bool resultObj = false; if (xType == yType) { resultObj = JSTaggedValue::StrictEqual(thread, JSHandle(thread, left), - JSHandle(thread, right)); + JSHandle(thread, right)); } ret = resultObj ? JSTaggedValue::True() : JSTaggedValue::False(); break; @@ -212,16 +212,16 @@ JSTaggedValue CompareOp::EqualWithIC(JSThread* thread, JSTaggedValue left, return ret; } -JSTaggedValue CompareOp::NotEqualWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType) +JSTaggedValue CompareOp::NotEqualWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType) { INTERPRETER_TRACE(thread, NotEqualWithIC); JSTaggedValue res = EqualWithIC(thread, left, right, operationType); return res == JSTaggedValue::True() ? JSTaggedValue::False() : JSTaggedValue::True(); } -ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType) +ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType) { INTERPRETER_TRACE(thread, Compare); double leftDouble = 0; @@ -258,14 +258,14 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, JSHandle rightPrimitive(thread, JSTaggedValue::ToPrimitive(thread, rightHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); if (rightPrimitive->IsNumber()) { - ret = Compare(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); + ret = Compare(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_NUMBER); } else if (rightPrimitive->IsString()) { - ret = Compare(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_STRING); + ret = Compare(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_STRING); } else if (rightPrimitive->IsBoolean()) { - ret = Compare(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_BOOLEAN); + ret = Compare(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_BOOLEAN); } break; } @@ -274,9 +274,9 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, auto yString = static_cast(right.GetTaggedObject()); int result = xString->Compare(yString); if (result < 0) { - ret = ComparisonResult::LESS; + ret = ComparisonResult::LESS; } else if (result == 0) { - ret = ComparisonResult::EQUAL; + ret = ComparisonResult::EQUAL; } else { ret = ComparisonResult::GREAT; } @@ -308,14 +308,14 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, JSHandle rightPrimitive(thread, JSTaggedValue::ToPrimitive(thread, rightHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); if (rightPrimitive->IsNumber()) { - ret = Compare(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::NUMBER_STRING); + ret = Compare(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::NUMBER_STRING); } else if (rightPrimitive->IsString()) { - ret = Compare(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::STRING_STRING); + ret = Compare(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::STRING_STRING); } else if (rightPrimitive->IsBoolean()) { - ret = Compare(thread, leftHandle.GetTaggedValue(), - rightPrimitive.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + ret = Compare(thread, leftHandle.GetTaggedValue(), rightPrimitive.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); } break; } @@ -357,14 +357,14 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, JSHandle rightPrimitive(thread, JSTaggedValue::ToPrimitive(thread, rightHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); if (rightPrimitive->IsNumber()) { - ret = Compare(thread, rightPrimitive.GetTaggedValue(), - leftHandle.GetTaggedValue(), CompareOpType::NUMBER_BOOLEAN); + ret = Compare(thread, rightPrimitive.GetTaggedValue(), leftHandle.GetTaggedValue(), + CompareOpType::NUMBER_BOOLEAN); } else if (rightPrimitive->IsString()) { - ret = Compare(thread, rightPrimitive.GetTaggedValue(), - leftHandle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + ret = Compare(thread, rightPrimitive.GetTaggedValue(), leftHandle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); } else if (rightPrimitive->IsBoolean()) { - ret = Compare(thread, rightPrimitive.GetTaggedValue(), - leftHandle.GetTaggedValue(), CompareOpType::BOOLEAN_BOOLEAN); + ret = Compare(thread, rightPrimitive.GetTaggedValue(), leftHandle.GetTaggedValue(), + CompareOpType::BOOLEAN_BOOLEAN); } break; } @@ -380,14 +380,14 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, JSHandle leftPrimitive(thread, JSTaggedValue::ToPrimitive(thread, leftHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); if (leftPrimitive->IsNumber()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::NUMBER_NUMBER); } else if (leftPrimitive->IsString()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::STRING_NUMBER); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::STRING_NUMBER); } else if (leftPrimitive->IsBoolean()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::BOOLEAN_NUMBER); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::BOOLEAN_NUMBER); } break; } @@ -397,14 +397,14 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, JSHandle leftPrimitive(thread, JSTaggedValue::ToPrimitive(thread, leftHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); if (leftPrimitive->IsNumber()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::NUMBER_STRING); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::NUMBER_STRING); } else if (leftPrimitive->IsString()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::STRING_STRING); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::STRING_STRING); } else if (leftPrimitive->IsBoolean()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::BOOLEAN_STRING); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::BOOLEAN_STRING); } break; } @@ -414,14 +414,14 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, JSHandle leftPrimitive(thread, JSTaggedValue::ToPrimitive(thread, leftHandle)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); if (leftPrimitive->IsNumber()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::NUMBER_BOOLEAN); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::NUMBER_BOOLEAN); } else if (leftPrimitive->IsString()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); } else if (leftPrimitive->IsBoolean()) { - ret = Compare(thread, leftPrimitive.GetTaggedValue(), - rightHandle.GetTaggedValue(), CompareOpType::BOOLEAN_BOOLEAN); + ret = Compare(thread, leftPrimitive.GetTaggedValue(), rightHandle.GetTaggedValue(), + CompareOpType::BOOLEAN_BOOLEAN); } break; } @@ -431,8 +431,8 @@ ComparisonResult CompareOp::Compare(JSThread *thread, JSTaggedValue left, return ret; } -JSTaggedValue CompareOp::LessDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType) +JSTaggedValue CompareOp::LessDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType) { INTERPRETER_TRACE(thread, LessDynWithIC); bool ret = CompareOp::Compare(thread, left, right, operationType) == ComparisonResult::LESS; @@ -440,8 +440,8 @@ JSTaggedValue CompareOp::LessDynWithIC(JSThread *thread, JSTaggedValue left, return (ret ? JSTaggedValue::True() : JSTaggedValue::False()); } -JSTaggedValue CompareOp::LessEqDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType) +JSTaggedValue CompareOp::LessEqDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType) { INTERPRETER_TRACE(thread, LessEqDynWithIC); bool ret = CompareOp::Compare(thread, left, right, operationType) <= ComparisonResult::EQUAL; @@ -449,8 +449,8 @@ JSTaggedValue CompareOp::LessEqDynWithIC(JSThread *thread, JSTaggedValue left, return (ret ? JSTaggedValue::True() : JSTaggedValue::False()); } -JSTaggedValue CompareOp::GreaterDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType) +JSTaggedValue CompareOp::GreaterDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType) { INTERPRETER_TRACE(thread, GreaterDynWithIC); bool ret = CompareOp::Compare(thread, left, right, operationType) == ComparisonResult::GREAT; @@ -458,8 +458,8 @@ JSTaggedValue CompareOp::GreaterDynWithIC(JSThread *thread, JSTaggedValue left, return (ret ? JSTaggedValue::True() : JSTaggedValue::False()); } -JSTaggedValue CompareOp::GreaterEqDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType) +JSTaggedValue CompareOp::GreaterEqDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType) { INTERPRETER_TRACE(thread, GreaterEqDynWithIC); ComparisonResult comparison = CompareOp::Compare(thread, left, right, operationType); @@ -467,4 +467,4 @@ JSTaggedValue CompareOp::GreaterEqDynWithIC(JSThread *thread, JSTaggedValue left RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); return (ret ? JSTaggedValue::True() : JSTaggedValue::False()); } -} // namespace panda::ecmascript +} // namespace panda::ecmascript diff --git a/runtime/ic/ic_compare_op.h b/runtime/ic/ic_compare_op.h index b88e0752c..43bea176f 100644 --- a/runtime/ic/ic_compare_op.h +++ b/runtime/ic/ic_compare_op.h @@ -49,30 +49,29 @@ enum class CompareOpType { class CompareOp { public: - CompareOp() = default; ~CompareOp() = default; - static JSTaggedValue EqualWithIC(JSThread* thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType); + static JSTaggedValue EqualWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType); - static JSTaggedValue NotEqualWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType); + static JSTaggedValue NotEqualWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType); - static ComparisonResult Compare(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType); + static ComparisonResult Compare(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType); - static JSTaggedValue LessDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType); + static JSTaggedValue LessDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType); - static JSTaggedValue LessEqDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType); + static JSTaggedValue LessEqDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType); - static JSTaggedValue GreaterDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType); + static JSTaggedValue GreaterDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType); - static JSTaggedValue GreaterEqDynWithIC(JSThread *thread, JSTaggedValue left, - JSTaggedValue right, CompareOpType operationType); + static JSTaggedValue GreaterEqDynWithIC(JSThread *thread, JSTaggedValue left, JSTaggedValue right, + CompareOpType operationType); }; -} // namespace panda::ecmascript +} // namespace panda::ecmascript #endif // ECMASCRIPT_IC_IC_COMPAREOP_H diff --git a/runtime/ic/ic_handler-inl.h b/runtime/ic/ic_handler-inl.h index f888ec865..ceb8c1614 100644 --- a/runtime/ic/ic_handler-inl.h +++ b/runtime/ic/ic_handler-inl.h @@ -63,8 +63,7 @@ JSHandle LoadHandler::LoadProperty(const JSThread *thread, const UNREACHABLE(); } -JSHandle PrototypeHandler::LoadPrototype(const JSThread *thread, - const ObjectOperator &op, +JSHandle PrototypeHandler::LoadPrototype(const JSThread *thread, const ObjectOperator &op, const JSHandle &hclass) { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -79,8 +78,7 @@ JSHandle PrototypeHandler::LoadPrototype(const JSThread *thread, return JSHandle::Cast(handler); } -JSHandle PrototypeHandler::StorePrototype(const JSThread *thread, - const ObjectOperator &op, +JSHandle PrototypeHandler::StorePrototype(const JSThread *thread, const ObjectOperator &op, const JSHandle &hclass) { ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); diff --git a/runtime/ic/invoke_cache.h b/runtime/ic/invoke_cache.h index 02435983f..2733f7f47 100644 --- a/runtime/ic/invoke_cache.h +++ b/runtime/ic/invoke_cache.h @@ -35,8 +35,7 @@ public: static JSTaggedValue CheckPolyInvokeCache(JSTaggedValue cachedArray, JSTaggedValue func); static JSTaggedValue Construct(JSThread *thread, JSTaggedValue firstValue, JSTaggedValue secondValue, - JSTaggedValue ctor, JSTaggedValue newTarget, uint16_t firstArgIdx, - uint16_t length); + JSTaggedValue ctor, JSTaggedValue newTarget, uint16_t firstArgIdx, uint16_t length); static bool SetMonoInlineCallCacheSlot(JSThread *thread, ProfileTypeInfo *profileTypeInfo, uint32_t slotId, JSTaggedValue callee); diff --git a/runtime/ic/profile_type_info.h b/runtime/ic/profile_type_info.h index ac9a673b3..a8584fbf2 100644 --- a/runtime/ic/profile_type_info.h +++ b/runtime/ic/profile_type_info.h @@ -66,15 +66,13 @@ static inline bool IsNamedIC(ICKind kind) static inline bool IsGlobalLoadIC(ICKind kind) { - return (kind == ICKind::NAMED_GLOBAL_LOAD_IC) || - (kind == ICKind::GLOBAL_LOAD_IC) || + return (kind == ICKind::NAMED_GLOBAL_LOAD_IC) || (kind == ICKind::GLOBAL_LOAD_IC) || (kind == ICKind::TRY_NAMED_GLOBAL_LOAD_IC); } static inline bool IsGlobalStoreIC(ICKind kind) { - return (kind == ICKind::NAMED_GLOBAL_STORE_IC) || - (kind == ICKind::GLOBAL_STORE_IC) || + return (kind == ICKind::NAMED_GLOBAL_STORE_IC) || (kind == ICKind::GLOBAL_STORE_IC) || (kind == ICKind::TRY_NAMED_GLOBAL_STORE_IC); } diff --git a/runtime/ic/properties_cache.h b/runtime/ic/properties_cache.h index f676db144..37be36b31 100644 --- a/runtime/ic/properties_cache.h +++ b/runtime/ic/properties_cache.h @@ -47,9 +47,9 @@ private: ~PropertiesCache() = default; struct PropertyKey { - JSHClass *hclass_{nullptr}; - JSTaggedValue key_{JSTaggedValue::Hole()}; - int results_{NOT_FOUND}; + JSHClass *hclass_ {nullptr}; + JSTaggedValue key_ {JSTaggedValue::Hole()}; + int results_ {NOT_FOUND}; }; static inline int Hash(JSHClass *cls, JSTaggedValue key); @@ -58,7 +58,7 @@ private: static const uint32_t CACHE_LENGTH = (1U << CACHE_LENGTH_BIT); static const uint32_t CACHE_LENGTH_MASK = CACHE_LENGTH - 1; - std::array keys_{}; + std::array keys_ {}; friend class JSThread; }; diff --git a/runtime/ic/proto_change_details.h b/runtime/ic/proto_change_details.h index dfd8bb2a6..d2b329d8d 100644 --- a/runtime/ic/proto_change_details.h +++ b/runtime/ic/proto_change_details.h @@ -25,7 +25,6 @@ namespace panda { namespace ecmascript { class ProtoChangeMarker : public TaggedObject { public: - using HasChangedField = BitField; static ProtoChangeMarker *Cast(ObjectHeader *object) { diff --git a/runtime/internal_call_params.cpp b/runtime/internal_call_params.cpp index 012509c3a..c3faa22d1 100644 --- a/runtime/internal_call_params.cpp +++ b/runtime/internal_call_params.cpp @@ -19,7 +19,7 @@ namespace panda::ecmascript { void InternalCallParams::MakeArgv(const EcmaRuntimeCallInfo *info, uint32_t position) { int32_t mayLenth = info->GetArgsNumber() - position; - uint32_t length = mayLenth > 0 ? mayLenth : 0; + uint32_t length = mayLenth > 0 ? mayLenth : 0; if (LIKELY(length <= InternalCallParams::RESERVE_INTERNAL_CALL_PARAMS_FIXED_LENGTH)) { EnableFixedModeAndSetLength(length); for (uint32_t index = 0; index < length; ++index) { @@ -77,8 +77,7 @@ void InternalCallParams::MakeBoundArgv(const JSThread *thread, const JSHandle boundArgs(thread, boundFunc->GetBoundArguments()); uint32_t boundLength = boundArgs->GetLength(); - uint32_t length = IsFixedMode() ? boundLength + GetFixedLength() - : boundLength + GetVariableLength(); + uint32_t length = IsFixedMode() ? boundLength + GetFixedLength() : boundLength + GetVariableLength(); if (LIKELY(length <= InternalCallParams::RESERVE_INTERNAL_CALL_PARAMS_FIXED_LENGTH)) { EnableFixedModeAndSetLength(length); diff --git a/runtime/internal_call_params.h b/runtime/internal_call_params.h index d4faf3a0a..6ba39e8a5 100644 --- a/runtime/internal_call_params.h +++ b/runtime/internal_call_params.h @@ -51,14 +51,14 @@ public: return variable_length_; } - template + template inline void MakeArgv(const JSHandle &arg) { EnableFixedModeAndSetLength(1); fixed_data_[0] = arg.GetTaggedType(); } - template + template inline void MakeArgv(const JSHandle &arg0, const JSHandle &arg1) { EnableFixedModeAndSetLength(2); @@ -66,7 +66,7 @@ public: fixed_data_[1] = arg1.GetTaggedType(); } - template + template inline void MakeArgv(const JSHandle &arg0, const JSHandle &arg1, const JSHandle &arg2) { EnableFixedModeAndSetLength(3); @@ -75,7 +75,7 @@ public: fixed_data_[2] = arg2.GetTaggedType(); } - template + template inline void MakeArgv(const JSHandle &arg0, const JSHandle &arg1, const JSHandle &arg2, const JSHandle &arg3) { @@ -221,11 +221,11 @@ private: variable_data_.insert(variable_data_.begin(), val.GetRawData()); } - std::array fixed_data_{}; - CVector variable_data_{}; - uint32_t fixed_length_{0}; - uint32_t variable_length_{0}; - bool variable_mode_{false}; + std::array fixed_data_ {}; + CVector variable_data_ {}; + uint32_t fixed_length_ {0}; + uint32_t variable_length_ {0}; + bool variable_mode_ {false}; }; } // namespace panda::ecmascript diff --git a/runtime/interpreter/fast_runtime_stub.h b/runtime/interpreter/fast_runtime_stub.h index 1151775f8..0346e7d14 100644 --- a/runtime/interpreter/fast_runtime_stub.h +++ b/runtime/interpreter/fast_runtime_stub.h @@ -69,19 +69,19 @@ public: /* -------------- Special API For Multi-Language VM End ----------------- */ /* -------------- Common API End, Don't change those interface!!! ----------------- */ - template + template static inline JSTaggedValue GetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); - template + template static inline JSTaggedValue GetPropertyByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); - template + template static inline JSTaggedValue GetPropertyByIndex(JSThread *thread, JSTaggedValue receiver, uint32_t index); - template + template static inline JSTaggedValue SetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, JSTaggedValue value); - template + template static inline JSTaggedValue SetPropertyByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key, JSTaggedValue value); - template + template static inline JSTaggedValue SetPropertyByIndex(JSThread *thread, JSTaggedValue receiver, uint32_t index, JSTaggedValue value); @@ -91,12 +91,11 @@ public: JSTaggedValue value); static inline JSTaggedValue FastGetPropertyByName(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); static inline JSTaggedValue FastGetPropertyByValue(JSThread *thread, JSTaggedValue receiver, JSTaggedValue key); - template + template static inline JSTaggedValue FastGetPropertyByIndex(JSThread *thread, JSTaggedValue receiver, uint32_t index); static inline PropertyAttributes AddPropertyByName(JSThread *thread, JSHandle objHandle, JSHandle keyHandle, - JSHandle valueHandle, - PropertyAttributes attr); + JSHandle valueHandle, PropertyAttributes attr); private: friend class ICRuntimeStub; diff --git a/runtime/interpreter/interpreter-inl.h b/runtime/interpreter/interpreter-inl.h index eaa0815fe..262428361 100644 --- a/runtime/interpreter/interpreter-inl.h +++ b/runtime/interpreter/interpreter-inl.h @@ -78,11 +78,11 @@ public: return ret; } - ALWAYS_INLINE static Frame *CreateFrame(ManagedThread *thread, uint32_t nregs_size, Method *method, - Frame *prev, uint32_t nregs, uint32_t num_actual_args) + ALWAYS_INLINE static Frame *CreateFrame(ManagedThread *thread, uint32_t nregs_size, Method *method, Frame *prev, + uint32_t nregs, uint32_t num_actual_args) { - return ::panda::CreateFrame(thread->GetStackFrameAllocator(), nregs_size, method, prev, - nregs, num_actual_args); + return ::panda::CreateFrame(thread->GetStackFrameAllocator(), nregs_size, method, prev, nregs, + num_actual_args); } }; diff --git a/runtime/interpreter/interpreter.h b/runtime/interpreter/interpreter.h index 691a6e9be..d24ded15a 100644 --- a/runtime/interpreter/interpreter.h +++ b/runtime/interpreter/interpreter.h @@ -32,13 +32,13 @@ public: static inline JSTaggedValue ExecuteNative(JSThread *thread, JSTaggedValue fn_object, uint32_t num_args, const JSTaggedValue *args); static inline JSTaggedValue ExecuteInvoke(JSThread *thread, JSTaggedValue fn_object, uint32_t num_args, - JSTaggedValue *args); + JSTaggedValue *args); static inline JSTaggedValue Execute(JSThread *thread, JSHandle callTarget, uint32_t numActualArgs, JSTaggedType *args); static inline JSTaggedValue ExecuteNative(JSThread *js_thread, JSHandle call_target, uint32_t num_args, const JSTaggedType *args); - static inline JSTaggedValue ExecuteInvoke(JSThread *js_thread, JSHandle call_target, - uint32_t num_args, JSTaggedValue *args); + static inline JSTaggedValue ExecuteInvoke(JSThread *js_thread, JSHandle call_target, uint32_t num_args, + JSTaggedValue *args); static inline JSTaggedValue GeneratorReEnterInterpreter(JSThread *thread, JSHandle context); static inline void ChangeGenContext(JSThread *thread, JSHandle context); static inline void ResumeContext(JSThread *thread); @@ -49,7 +49,7 @@ public: static inline size_t GetJumpSizeAfterCall(const uint8_t *prevPc); static inline JSTaggedValue GetRuntimeProfileTypeInfo(JSTaggedType *sp); - static inline bool UpdateHotnessCounter(JSThread* thread, JSTaggedType *sp, JSTaggedValue acc, int32_t offset); + static inline bool UpdateHotnessCounter(JSThread *thread, JSTaggedType *sp, JSTaggedValue acc, int32_t offset); static inline void InterpreterFrameCopyArgs(JSTaggedType *newSp, uint32_t numVregs, uint32_t numActualArgs, uint32_t numDeclaredArgs, bool haveExtraArgs = true); static inline void NotifyBytecodePcChanged(JSThread *thread); diff --git a/runtime/interpreter/js_frame-inl.h b/runtime/interpreter/js_frame-inl.h index a2ea30ef8..f8f050f2e 100644 --- a/runtime/interpreter/js_frame-inl.h +++ b/runtime/interpreter/js_frame-inl.h @@ -17,8 +17,8 @@ inline Frame *JSFrame::CreateNativeFrame(JSThread *js_thread, Method *method, Fr { ASSERT(js_thread == JSThread::GetCurrent()); - Frame *new_frame = CreateFrame(js_thread->GetStackFrameAllocator(), nregs, method, prev_frame, nregs, - num_actual_args); + Frame *new_frame = + CreateFrame(js_thread->GetStackFrameAllocator(), nregs, method, prev_frame, nregs, num_actual_args); js_thread->SetCurrentFrame(new_frame); LOG_IF(new_frame == nullptr, FATAL, ECMASCRIPT) << "Cannot allocate native frame"; new_frame->SetInvoke(); diff --git a/runtime/jobs/micro_job_queue.cpp b/runtime/jobs/micro_job_queue.cpp index e0623b5c2..620905c1f 100644 --- a/runtime/jobs/micro_job_queue.cpp +++ b/runtime/jobs/micro_job_queue.cpp @@ -28,7 +28,7 @@ namespace panda::ecmascript::job { void MicroJobQueue::EnqueueJob(JSThread *thread, JSHandle jobQueue, QueueType queueType, - const JSHandle &job, const JSHandle &argv) + const JSHandle &job, const JSHandle &argv) { // 1. Assert: Type(queueName) is String and its value is the name of a Job Queue recognized by this implementation. // 2. Assert: job is the name of a Job. diff --git a/runtime/jobs/micro_job_queue.h b/runtime/jobs/micro_job_queue.h index 919494153..d1cde4990 100644 --- a/runtime/jobs/micro_job_queue.h +++ b/runtime/jobs/micro_job_queue.h @@ -41,7 +41,7 @@ public: } static void EnqueueJob(JSThread *thread, JSHandle jobQueue, QueueType queueType, - const JSHandle &job, const JSHandle &argv); + const JSHandle &job, const JSHandle &argv); static void ExecutePendingJob(JSThread *thread, JSHandle jobQueue); static constexpr size_t PROMISE_JOB_QUEUE_OFFSET = Record::SIZE; diff --git a/runtime/js_arraylist.cpp b/runtime/js_arraylist.cpp index 01f8ca1c1..2982c83fe 100644 --- a/runtime/js_arraylist.cpp +++ b/runtime/js_arraylist.cpp @@ -104,8 +104,8 @@ JSHandle JSArrayList::OwnKeys(JSThread *thread, const JSHandle &obj, - const JSHandle &key, PropertyDescriptor &desc) +bool JSArrayList::GetOwnProperty(JSThread *thread, const JSHandle &obj, const JSHandle &key, + PropertyDescriptor &desc) { uint32_t index = 0; if (UNLIKELY(JSTaggedValue::ToElementIndex(key.GetTaggedValue(), &index))) { diff --git a/runtime/js_collator.h b/runtime/js_collator.h index 0780d6755..f307bbfdf 100644 --- a/runtime/js_collator.h +++ b/runtime/js_collator.h @@ -68,8 +68,8 @@ public: icuCollator->~Collator(); } - static void SetIcuCollator(JSThread *thread, const JSHandle &collator, - icu::Collator *icuCollator, const DeleteEntryPoint &callback); + static void SetIcuCollator(JSThread *thread, const JSHandle &collator, icu::Collator *icuCollator, + const DeleteEntryPoint &callback); // 11.1.1 InitializeCollator ( collator, locales, options ) static JSHandle InitializeCollator(JSThread *thread, const JSHandle &collator, diff --git a/runtime/js_date.cpp b/runtime/js_date.cpp index 54ce155d3..a88561f02 100644 --- a/runtime/js_date.cpp +++ b/runtime/js_date.cpp @@ -237,10 +237,8 @@ JSTaggedValue JSDate::LocalParseStringToMs(const CString &str) bool isLocal = false; CString::size_type indexGmt; CString::size_type indexPlus = CString::npos; - std::array monthName = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; + std::array monthName = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; int localTime = 0; int localHours = 0; int localMinutes = 0; @@ -311,10 +309,8 @@ JSTaggedValue JSDate::UtcParseStringToMs(const CString &str) int localMinutes = 0; int64_t localMs = 0; bool isLocal = false; - std::array monthName = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; + std::array monthName = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; GetNumFromString(str, len, &index, &date); CString strMonth = str.substr(index + 1, LENGTH_MONTH_NAME); for (int i = 0; i < MOUTH_PER_YEAR; i++) { @@ -634,10 +630,8 @@ bool JSDate::GetThisDateValues(std::array *date, bool isLo // 20.4.4.35 JSTaggedValue JSDate::ToDateString(JSThread *thread) const { - std::array monthName = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; + std::array monthName = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; std::array weekdayName = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; std::array fields = {0}; if (!GetThisDateValues(&fields, true)) { @@ -656,10 +650,8 @@ CString JSDate::ToDateString(double timeMs) if (std::isnan(timeMs)) { return "Invalid Date"; } - std::array monthName = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; + std::array monthName = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; std::array weekdayName = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; std::array fields = {0}; GetDateValues(timeMs, &fields, true); @@ -786,10 +778,8 @@ JSTaggedValue JSDate::ToLocaleTimeString(JSThread *thread) const JSTaggedValue JSDate::ToString(JSThread *thread) const { std::array weekdayName = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; - std::array monthName = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; + std::array monthName = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; int localMin = 0; std::array fields = {0}; if (!GetThisDateValues(&fields, true)) { @@ -855,10 +845,8 @@ JSTaggedValue JSDate::ToTimeString(JSThread *thread) const JSTaggedValue JSDate::ToUTCString(JSThread *thread) const { std::array weekdayName = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; - std::array monthName = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; + std::array monthName = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; std::array fields = {0}; if (!GetThisDateValues(&fields, false)) { return JSTaggedValue(base::NAN_VALUE); @@ -907,7 +895,7 @@ void JSDate::GetDateValues(double timeMs, std::array *date int left = 0; int right = MONTH_PER_YEAR; while (left <= right) { - int middle = (left + right) / 2; // 2 : half + int middle = (left + right) / 2; // 2 : half if (DAYS_FROM_MONTH[index][middle] <= (*date)[DAYS] && DAYS_FROM_MONTH[index][middle + 1] > (*date)[DAYS]) { month = middle; (*date)[DAYS] -= DAYS_FROM_MONTH[index][month]; diff --git a/runtime/js_invoker.h b/runtime/js_invoker.h index 9251ed96d..152397986 100644 --- a/runtime/js_invoker.h +++ b/runtime/js_invoker.h @@ -41,13 +41,13 @@ public: NO_COPY_SEMANTIC(JsInvoker); NO_MOVE_SEMANTIC(JsInvoker); - template + template void AddArgument(const JSHandle &arg) { args_.emplace_back(JSHandle(arg)); } - template + template void AddArgument(JSHandle &&arg) { args_.emplace_back(std::move(arg)); @@ -56,7 +56,7 @@ public: JSTaggedValue Invoke(JSThread *thread); private: - CVector> args_{}; + CVector> args_ {}; }; JSTaggedValue InvokeJsFunction(JSThread *thread, const JSHandle &func, const JSHandle &obj, diff --git a/runtime/js_number_format.cpp b/runtime/js_number_format.cpp index 2717db558..7da773c73 100644 --- a/runtime/js_number_format.cpp +++ b/runtime/js_number_format.cpp @@ -245,8 +245,7 @@ bool IsWellFormedUnitIdentifier(const std::string &unit, icu::MeasureUnit &icuUn } // 12.1.13 SetNumberFormatUnitOptions ( intlObj, options ) -FractionDigitsOption SetNumberFormatUnitOptions(JSThread *thread, - const JSHandle &numberFormat, +FractionDigitsOption SetNumberFormatUnitOptions(JSThread *thread, const JSHandle &numberFormat, const JSHandle &optionsObject, icu::number::LocalizedNumberFormatter *icuNumberFormatter) { @@ -487,7 +486,7 @@ void JSNumberFormat::InitializeNumberFormat(JSThread *thread, const JSHandle relevantExtensionKeys{"nu"}; + std::set relevantExtensionKeys {"nu"}; ResolvedLocale r = JSLocale::ResolveLocale(thread, availableLocales, requestedLocales, matcher, relevantExtensionKeys); diff --git a/runtime/js_number_format.h b/runtime/js_number_format.h index 419026c94..ae58956b3 100644 --- a/runtime/js_number_format.h +++ b/runtime/js_number_format.h @@ -42,13 +42,21 @@ struct FractionDigitsOption { }; // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static const std::set sanctionedUnit({ "acre", "bit", "byte", "celsius", "centimeter", "day", "degree", - "fahrenheit", "fluid-ounce", "foot", "gallon", "gigabit", "gigabyte", - "gram", "hectare", "hour", "inch", "kilobit", "kilobyte", "kilogram", - "kilometer", "liter", "megabit", "megabyte", "meter", "mile", - "mile-scandinavian", "millimeter", "milliliter", "millisecond", - "minute", "month", "ounce", "percent", "petabyte", "pound", "second", - "stone", "terabit", "terabyte", "week", "yard", "year" }); +static const std::set sanctionedUnit({"acre", "bit", "byte", + "celsius", "centimeter", "day", + "degree", "fahrenheit", "fluid-ounce", + "foot", "gallon", "gigabit", + "gigabyte", "gram", "hectare", + "hour", "inch", "kilobit", + "kilobyte", "kilogram", "kilometer", + "liter", "megabit", "megabyte", + "meter", "mile", "mile-scandinavian", + "millimeter", "milliliter", "millisecond", + "minute", "month", "ounce", + "percent", "petabyte", "pound", + "second", "stone", "terabit", + "terabyte", "week", "yard", + "year"}); class JSNumberFormat : public JSObject { public: @@ -123,7 +131,7 @@ public: static void ResolvedOptions(JSThread *thread, const JSHandle &numberFormat, const JSHandle &options); - template + template static icu::number::LocalizedNumberFormatter SetICUFormatterDigitOptions( icu::number::LocalizedNumberFormatter &icuNumberformatter, const JSHandle &formatter) { diff --git a/runtime/js_object.h b/runtime/js_object.h index 3385e81f7..56ac39b44 100644 --- a/runtime/js_object.h +++ b/runtime/js_object.h @@ -210,7 +210,7 @@ public: static void CompletePropertyDescriptor(const JSThread *thread, PropertyDescriptor &desc); private: - const JSThread *thread_{nullptr}; + const JSThread *thread_ {nullptr}; bool writable_ {false}; bool enumerable_ {false}; @@ -285,7 +285,7 @@ public: } private: - uint32_t metaData_{0}; + uint32_t metaData_ {0}; }; class OperationResult { @@ -323,7 +323,7 @@ public: private: const JSThread *thread_ {nullptr}; JSHandle value_ {}; - PropertyMetaData metaData_{0U}; + PropertyMetaData metaData_ {0U}; }; class ECMAObject : public TaggedObject { @@ -347,9 +347,8 @@ public: ObjectAccessor::SetDynValueWithoutBarrier(this, ECMAObject::HASH_OFFSET, JSTaggedValue(0).GetRawData()); } - void* GetNativePointerField(int32_t index) const; - void SetNativePointerField(int32_t index, void *nativePointer, - const DeleteEntryPoint &callBack, void *data); + void *GetNativePointerField(int32_t index) const; + void SetNativePointerField(int32_t index, void *nativePointer, const DeleteEntryPoint &callBack, void *data); int32_t GetNativePointerFieldCount() const; void SetNativePointerFieldCount(int32_t count); @@ -417,7 +416,7 @@ public: static JSHandle SpeciesConstructor(JSThread *thread, const JSHandle &obj, const JSHandle &defaultConstructort); // 7.3.17 - template + template static JSHandle CreateListFromArrayLike(JSThread *thread, const JSHandle &obj); // emca6 9.1 diff --git a/runtime/js_plural_rules.cpp b/runtime/js_plural_rules.cpp index 80614179f..a31b17cf0 100644 --- a/runtime/js_plural_rules.cpp +++ b/runtime/js_plural_rules.cpp @@ -32,7 +32,7 @@ icu::number::LocalizedNumberFormatter *JSPluralRules::GetIcuNumberFormatter() co return reinterpret_cast(result); } -void JSPluralRules::FreeIcuNumberFormatter(void *pointer, [[maybe_unused]] void* hint) +void JSPluralRules::FreeIcuNumberFormatter(void *pointer, [[maybe_unused]] void *hint) { if (pointer == nullptr) { return; @@ -42,7 +42,8 @@ void JSPluralRules::FreeIcuNumberFormatter(void *pointer, [[maybe_unused]] void* } void JSPluralRules::SetIcuNumberFormatter(JSThread *thread, const JSHandle &pluralRules, - const icu::number::LocalizedNumberFormatter &icuNF, const DeleteEntryPoint &callback) + const icu::number::LocalizedNumberFormatter &icuNF, + const DeleteEntryPoint &callback) { EcmaVM *ecmaVm = thread->GetEcmaVM(); ObjectFactory *factory = ecmaVm->GetFactory(); @@ -69,7 +70,7 @@ icu::PluralRules *JSPluralRules::GetIcuPluralRules() const return reinterpret_cast(result); } -void JSPluralRules::FreeIcuPluralRules(void *pointer, [[maybe_unused]] void* hint) +void JSPluralRules::FreeIcuPluralRules(void *pointer, [[maybe_unused]] void *hint) { if (pointer == nullptr) { return; @@ -79,7 +80,7 @@ void JSPluralRules::FreeIcuPluralRules(void *pointer, [[maybe_unused]] void* hin } void JSPluralRules::SetIcuPluralRules(JSThread *thread, const JSHandle &pluralRules, - const icu::PluralRules &icuPR, const DeleteEntryPoint &callback) + const icu::PluralRules &icuPR, const DeleteEntryPoint &callback) { [[maybe_unused]] EcmaHandleScope scope(thread); EcmaVM *ecmaVm = thread->GetEcmaVM(); @@ -176,8 +177,8 @@ JSHandle JSPluralRules::InitializePluralRules(JSThread *thread, // 7. Let t be ? GetOption(options, "type", "string", « "cardinal", "ordinal" », "cardinal"). JSHandle property = JSHandle::Cast(globalConst->GetHandledTypeString()); TypeOption type = - JSLocale::GetOptionOfString(thread, prOptions, property, { TypeOption::CARDINAL, TypeOption::ORDINAL }, - { "cardinal", "ordinal" }, TypeOption::CARDINAL); + JSLocale::GetOptionOfString(thread, prOptions, property, {TypeOption::CARDINAL, TypeOption::ORDINAL}, + {"cardinal", "ordinal"}, TypeOption::CARDINAL); RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSPluralRules, thread); // set pluralRules.[[type]] to type @@ -197,7 +198,7 @@ JSHandle JSPluralRules::InitializePluralRules(JSThread *thread, } else { availableLocales = GetAvailableLocales(thread); } - std::set relevantExtensionKeys{""}; + std::set relevantExtensionKeys {""}; ResolvedLocale r = JSLocale::ResolveLocale(thread, availableLocales, requestedLocales, matcher, relevantExtensionKeys); RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSPluralRules, thread); diff --git a/runtime/js_plural_rules.h b/runtime/js_plural_rules.h index 3ee3b9480..39741cf11 100644 --- a/runtime/js_plural_rules.h +++ b/runtime/js_plural_rules.h @@ -51,16 +51,17 @@ public: icu::number::LocalizedNumberFormatter *GetIcuNumberFormatter() const; static void SetIcuNumberFormatter(JSThread *thread, const JSHandle &pluralRules, - const icu::number::LocalizedNumberFormatter &icuNF, const DeleteEntryPoint &callback); + const icu::number::LocalizedNumberFormatter &icuNF, + const DeleteEntryPoint &callback); - static void FreeIcuNumberFormatter(void *pointer, [[maybe_unused]] void* hint = nullptr); + static void FreeIcuNumberFormatter(void *pointer, [[maybe_unused]] void *hint = nullptr); icu::PluralRules *GetIcuPluralRules() const; static void SetIcuPluralRules(JSThread *thread, const JSHandle &pluralRules, - const icu::PluralRules &icuPR, const DeleteEntryPoint &callback); + const icu::PluralRules &icuPR, const DeleteEntryPoint &callback); - static void FreeIcuPluralRules(void *pointer, [[maybe_unused]] void* hint = nullptr); + static void FreeIcuPluralRules(void *pointer, [[maybe_unused]] void *hint = nullptr); static JSHandle BuildLocaleSet(JSThread *thread, const std::set &icuAvailableLocales); diff --git a/runtime/js_proxy.h b/runtime/js_proxy.h index 8dee8cc15..a2fa88894 100644 --- a/runtime/js_proxy.h +++ b/runtime/js_proxy.h @@ -86,7 +86,7 @@ public: static JSTaggedValue ConstructInternal( // NOLINTNEXTLINE(modernize-avoid-c-arrays) JSThread *thread, const JSHandle &proxy, uint32_t argc, const JSTaggedType argv[], - const JSHandle &newTarget); + const JSHandle &newTarget); static constexpr size_t METHOD_OFFSET = ECMAObject::SIZE; SET_GET_NATIVE_FIELD(Method, JSMethod, METHOD_OFFSET, TARGET_OFFSET) diff --git a/runtime/js_stable_array.cpp b/runtime/js_stable_array.cpp index fecd2990f..9da15c51b 100644 --- a/runtime/js_stable_array.cpp +++ b/runtime/js_stable_array.cpp @@ -68,8 +68,8 @@ JSTaggedValue JSStableArray::Pop(JSHandle receiver, EcmaRuntimeCallInfo return result; } -JSTaggedValue JSStableArray::Splice(JSHandle receiver, EcmaRuntimeCallInfo *argv, - double start, double insertCount, double actualDeleteCount) +JSTaggedValue JSStableArray::Splice(JSHandle receiver, EcmaRuntimeCallInfo *argv, double start, + double insertCount, double actualDeleteCount) { JSThread *thread = argv->GetThread(); uint32_t len = receiver->GetArrayLength(); @@ -117,8 +117,7 @@ JSTaggedValue JSStableArray::Splice(JSHandle receiver, EcmaRuntimeCallI } JSHandle deleteCount(thread, JSTaggedValue(actualDeleteCount)); - JSTaggedValue::SetProperty(thread, JSHandle::Cast(newArrayHandle), lengthKey, deleteCount, - true); + JSTaggedValue::SetProperty(thread, JSHandle::Cast(newArrayHandle), lengthKey, deleteCount, true); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); } diff --git a/runtime/js_stable_array.h b/runtime/js_stable_array.h index 66e634538..7b8f9e939 100644 --- a/runtime/js_stable_array.h +++ b/runtime/js_stable_array.h @@ -26,8 +26,8 @@ public: enum SeparatorFlag : int { MINUS_ONE = -1, MINUS_TWO = -2 }; static JSTaggedValue Push(JSHandle receiver, EcmaRuntimeCallInfo *argv); static JSTaggedValue Pop(JSHandle receiver, EcmaRuntimeCallInfo *argv); - static JSTaggedValue Splice(JSHandle receiver, EcmaRuntimeCallInfo *argv, - double start, double insertCount, double actualDeleteCount); + static JSTaggedValue Splice(JSHandle receiver, EcmaRuntimeCallInfo *argv, double start, double insertCount, + double actualDeleteCount); static JSTaggedValue Shift(JSHandle receiver, EcmaRuntimeCallInfo *argv); static JSTaggedValue Join(JSHandle receiver, EcmaRuntimeCallInfo *argv); }; diff --git a/runtime/js_typed_array.cpp b/runtime/js_typed_array.cpp index e3a965bc3..b41f0f7dc 100644 --- a/runtime/js_typed_array.cpp +++ b/runtime/js_typed_array.cpp @@ -210,8 +210,8 @@ OperationResult JSTypedArray::GetProperty(JSThread *thread, const JSHandle(object); } diff --git a/runtime/layout_info.cpp b/runtime/layout_info.cpp index fb1753a36..1211b9e8f 100644 --- a/runtime/layout_info.cpp +++ b/runtime/layout_info.cpp @@ -82,8 +82,7 @@ void LayoutInfo::GetAllKeys([[maybe_unused]] const JSThread *thread, int end, st } } -void LayoutInfo::GetAllEnumKeys(const JSThread *thread, int end, int offset, TaggedArray *keyArray, - uint32_t *keys) +void LayoutInfo::GetAllEnumKeys(const JSThread *thread, int end, int offset, TaggedArray *keyArray, uint32_t *keys) { ASSERT(end <= NumberOfElements()); ASSERT_PRINT(offset + end <= static_cast(keyArray->GetLength()), @@ -101,8 +100,7 @@ void LayoutInfo::GetAllEnumKeys(const JSThread *thread, int end, int offset, Tag *keys += enumKeys; } -void LayoutInfo::GetAllNames(const JSThread *thread, int end, const JSHandle &keyArray, - uint32_t *length) +void LayoutInfo::GetAllNames(const JSThread *thread, int end, const JSHandle &keyArray, uint32_t *length) { DISALLOW_GARBAGE_COLLECTION; int arrayIndex = 0; diff --git a/runtime/linked_hash_table-inl.h b/runtime/linked_hash_table-inl.h index 0d8f7a917..7ab230b9c 100644 --- a/runtime/linked_hash_table-inl.h +++ b/runtime/linked_hash_table-inl.h @@ -21,83 +21,83 @@ #include "utils/bit_utils.h" namespace panda::ecmascript { -template +template JSTaggedValue LinkedHashTable::GetElement(int index) const { ASSERT(index >= 0 && index < static_cast(GetLength())); return Get(index); } -template +template void LinkedHashTable::SetElement(const JSThread *thread, int index, JSTaggedValue element) { ASSERT(index >= 0 && index < static_cast(GetLength())); Set(thread, index, element); } -template +template int LinkedHashTable::NumberOfElements() const { return Get(NUMBER_OF_ELEMENTS_INDEX).GetInt(); } -template +template int LinkedHashTable::NumberOfDeletedElements() const { return Get(NUMBER_OF_DELETED_ELEMENTS_INDEX).GetInt(); } -template +template int LinkedHashTable::Capacity() const { return JSTaggedValue(Get(CAPACITY_INDEX)).GetInt(); } -template +template void LinkedHashTable::SetNumberOfElements(const JSThread *thread, int nof) { Set(thread, NUMBER_OF_ELEMENTS_INDEX, JSTaggedValue(nof)); } -template +template void LinkedHashTable::SetNumberOfDeletedElements(const JSThread *thread, int nod) { Set(thread, NUMBER_OF_DELETED_ELEMENTS_INDEX, JSTaggedValue(nod)); } -template +template void LinkedHashTable::SetCapacity(const JSThread *thread, int capacity) { Set(thread, CAPACITY_INDEX, JSTaggedValue(capacity)); } -template +template void LinkedHashTable::SetNextTable(const JSThread *thread, JSTaggedValue nextTable) { Set(thread, NEXT_TABLE_INDEX, nextTable); } -template +template JSTaggedValue LinkedHashTable::GetNextTable() const { return JSTaggedValue(Get(NEXT_TABLE_INDEX)); } -template +template int LinkedHashTable::GetDeletedNum(int entry) const { ASSERT_PRINT(!GetNextTable().IsUndefined(), "function only execute after rehash"); return GetNextEntry(entry).GetInt(); } -template +template void LinkedHashTable::SetDeletedNum(const JSThread *thread, int entry, JSTaggedValue num) { ASSERT_PRINT(!GetNextTable().IsUndefined(), "function only execute after rehash"); SetNextEntry(thread, entry, num); } -template +template int LinkedHashTable::GetDeletedElementsAt(int entry) const { ASSERT_PRINT(!GetNextTable().IsUndefined(), "function only execute after rehash"); @@ -111,67 +111,67 @@ int LinkedHashTable::GetDeletedElementsAt(int entry) const return 0; } -template +template uint32_t LinkedHashTable::HashToBucket(uint32_t hash) const { return hash & static_cast(Capacity() - 1); } -template +template uint32_t LinkedHashTable::BucketToIndex(uint32_t bucket) { return bucket + ELEMENTS_START_INDEX; } -template +template uint32_t LinkedHashTable::EntryToIndex(uint32_t entry) const { return ELEMENTS_START_INDEX + Capacity() + entry * (HashObject::ENTRY_SIZE + 1); } -template +template void LinkedHashTable::SetKey(const JSThread *thread, int entry, JSTaggedValue key) { int index = EntryToIndex(entry); SetElement(thread, index, key); } -template +template JSTaggedValue LinkedHashTable::GetKey(int entry) const { int index = EntryToIndex(entry); return GetElement(index); } -template +template JSTaggedValue LinkedHashTable::GetValue(int entry) const { int index = EntryToIndex(entry) + HashObject::ENTRY_VALUE_INDEX; return GetElement(index); } -template +template void LinkedHashTable::SetValue(const JSThread *thread, int entry, JSTaggedValue value) { int index = EntryToIndex(entry) + HashObject::ENTRY_VALUE_INDEX; SetElement(thread, index, value); } -template +template JSTaggedValue LinkedHashTable::GetNextEntry(int entry) const { int index = EntryToIndex(entry) + HashObject::ENTRY_SIZE; return GetElement(index); } -template +template void LinkedHashTable::SetNextEntry(const JSThread *thread, int entry, JSTaggedValue nextEntry) { int index = EntryToIndex(entry) + HashObject::ENTRY_SIZE; SetElement(thread, index, nextEntry); } -template +template void LinkedHashTable::InsertNewEntry(const JSThread *thread, int bucket, int entry) { int bucketIndex = BucketToIndex(bucket); @@ -180,7 +180,7 @@ void LinkedHashTable::InsertNewEntry(const JSThread *thread SetElement(thread, bucketIndex, JSTaggedValue(entry)); } -template +template int LinkedHashTable::FindElement(JSTaggedValue key) const { if (!IsKey(key)) { @@ -204,7 +204,7 @@ int LinkedHashTable::FindElement(JSTaggedValue key) const return -1; } // namespace panda::ecmascript -template +template bool LinkedHashTable::HasSufficientCapacity(int numOfAddElements) const { int numberOfElements = NumberOfElements(); @@ -223,7 +223,7 @@ bool LinkedHashTable::HasSufficientCapacity(int numOfAddEle return false; } -template +template int LinkedHashTable::ComputeCapacity(uint32_t atLeastSpaceFor) { // Add 50% slack to make slot collisions sufficiently unlikely. @@ -233,7 +233,7 @@ int LinkedHashTable::ComputeCapacity(uint32_t atLeastSpaceF return (capacity > MIN_CAPACITY) ? capacity : MIN_CAPACITY; } -template +template void LinkedHashTable::RemoveEntry(const JSThread *thread, int entry) { ASSERT_PRINT(entry >= 0 && entry < Capacity(), "entry must be a non-negative integer less than capacity"); @@ -245,7 +245,7 @@ void LinkedHashTable::RemoveEntry(const JSThread *thread, i SetNumberOfDeletedElements(thread, NumberOfDeletedElements() + 1); } -template +template int LinkedHashTable::ComputeCapacityWithShrink(int currentCapacity, int atLeastSpaceFor) { // Shrink to fit the number of elements if only a quarter of the diff --git a/runtime/linked_hash_table.h b/runtime/linked_hash_table.h index 180ff050d..8730c1db4 100644 --- a/runtime/linked_hash_table.h +++ b/runtime/linked_hash_table.h @@ -48,7 +48,7 @@ public: const JSHandle &key, const JSHandle &value); static JSHandle GrowCapacity(const JSThread *thread, const JSHandle &table, - int numberOfAddedElements = 1); + int numberOfAddedElements = 1); static JSHandle Remove(const JSThread *thread, const JSHandle &table, const JSHandle &key); diff --git a/runtime/mem/allocator.h b/runtime/mem/allocator.h index cc7e30b63..8c9d76e4c 100644 --- a/runtime/mem/allocator.h +++ b/runtime/mem/allocator.h @@ -130,7 +130,7 @@ private: BumpPointerAllocator bpAllocator_; std::unique_ptr freeList_; - Heap *heap_{nullptr}; + Heap *heap_ {nullptr}; MemSpaceType type_ = OLD_SPACE; bool sweeping_ = false; size_t allocationSizeAccumulator_ = 0; diff --git a/runtime/mem/area.h b/runtime/mem/area.h index 23531d5b6..62ffccbbe 100644 --- a/runtime/mem/area.h +++ b/runtime/mem/area.h @@ -54,7 +54,7 @@ public: } private: - template + template friend class EcmaList; friend class Worker; Area *GetPrev() const diff --git a/runtime/mem/assert_scope-inl.h b/runtime/mem/assert_scope-inl.h index d2388e0bd..d2bde54fd 100644 --- a/runtime/mem/assert_scope-inl.h +++ b/runtime/mem/assert_scope-inl.h @@ -23,7 +23,7 @@ namespace panda::ecmascript { // NOLINTNEXTLINE(hicpp-signed-bitwise) static thread_local size_t currentAssertData(~0); -template +template AssertScopeT::AssertScopeT() : oldData_(currentAssertData) { switch (type) { @@ -38,7 +38,7 @@ AssertScopeT::AssertScopeT() : oldData_(currentAssertData) } } -template +template AssertScopeT::~AssertScopeT() { if (!oldData_.has_value()) { @@ -50,7 +50,7 @@ AssertScopeT::~AssertScopeT() } // static -template +template bool AssertScopeT::IsAllowed() { switch (type) { diff --git a/runtime/mem/assert_scope.h b/runtime/mem/assert_scope.h index 1bb100685..a999f5c40 100644 --- a/runtime/mem/assert_scope.h +++ b/runtime/mem/assert_scope.h @@ -33,7 +33,7 @@ constexpr bool IS_ALLOW_CHECK = false; enum class AssertType : uint8_t { GARBAGE_COLLECTION_ASSERT = 0, HEAP_ALLOC_ASSERT, LAST_ASSERT_TYPE }; -template +template class AssertScopeT { public: static bool IsAllowed() @@ -42,7 +42,7 @@ public: } }; -template +template class AssertScopeT { public: AssertScopeT(); diff --git a/runtime/mem/barriers-inl.h b/runtime/mem/barriers-inl.h index b0fb0f510..f28075e02 100644 --- a/runtime/mem/barriers-inl.h +++ b/runtime/mem/barriers-inl.h @@ -16,7 +16,6 @@ #ifndef ECMASCRIPT_MEM_BARRIERS_INL_H #define ECMASCRIPT_MEM_BARRIERS_INL_H - #include "plugins/ecmascript/runtime/js_thread.h" #include "plugins/ecmascript/runtime/mem/barriers.h" #include "plugins/ecmascript/runtime/mem/mem.h" @@ -26,8 +25,7 @@ #include "libpandabase/mem/gc_barrier.h" namespace panda::ecmascript { -static inline void MarkingBarrier(uintptr_t slotAddr, Region *objectRegion, TaggedObject *value, - Region *valueRegion) +static inline void MarkingBarrier(uintptr_t slotAddr, Region *objectRegion, TaggedObject *value, Region *valueRegion) { auto heap = valueRegion->GetHeap(); bool isOnlySemi = heap->IsSemiMarkNeeded(); diff --git a/runtime/mem/barriers.h b/runtime/mem/barriers.h index 6c57e83a1..cd1f3cd6b 100644 --- a/runtime/mem/barriers.h +++ b/runtime/mem/barriers.h @@ -21,7 +21,7 @@ namespace panda::ecmascript { class Barriers { public: - template + template static inline bool AtomicSetDynPrimitive(volatile void *obj, size_t offset, T oldValue, T value) { volatile auto atomicField = reinterpret_cast *>(ToUintPtr(obj) + offset); diff --git a/runtime/mem/c_containers.h b/runtime/mem/c_containers.h index 29caa67c2..3d1ff7cc6 100644 --- a/runtime/mem/c_containers.h +++ b/runtime/mem/c_containers.h @@ -31,32 +31,32 @@ #include "plugins/ecmascript/runtime/mem/caddress_allocator.h" namespace panda::ecmascript { -template +template using CVector = std::vector>; -template +template using CList = std::list>; -template> +template > using CMap = std::map>>; -template> +template > using CMultiMap = std::multimap>>; -template, class KeyEqual = std::equal_to> +template , class KeyEqual = std::equal_to> using CUnorderedMultiMap = std::unordered_multimap>>; -template +template using CDeque = std::deque>; -template> +template > using CQueue = std::queue; -template, class KeyEqual = std::equal_to> +template , class KeyEqual = std::equal_to> using CUnorderedMap = std::unordered_map>>; -template, class KeyEqual = std::equal_to> +template , class KeyEqual = std::equal_to> using CUnorderedSet = std::unordered_set>; } // namespace panda::ecmascript diff --git a/runtime/mem/c_string.cpp b/runtime/mem/c_string.cpp index 2d86c01ae..959db4c50 100644 --- a/runtime/mem/c_string.cpp +++ b/runtime/mem/c_string.cpp @@ -60,7 +60,7 @@ double CStringToD(const CString &str) return result; } -template +template CString ConvertToString(T sp) { CString res; diff --git a/runtime/mem/caddress_allocator.h b/runtime/mem/caddress_allocator.h index 1aee597d3..bf7071d7b 100644 --- a/runtime/mem/caddress_allocator.h +++ b/runtime/mem/caddress_allocator.h @@ -19,7 +19,7 @@ #include "plugins/ecmascript/runtime/mem/chunk.h" namespace panda::ecmascript { -template +template class CAddressAllocator { public: // using by std allocator @@ -31,17 +31,17 @@ public: using size_type = size_t; using difference_type = ptrdiff_t; - template + template struct Rebind { using other = CAddressAllocator; }; - template + template using rebind = Rebind; CAddressAllocator() = default; - template + template explicit CAddressAllocator(const CAddressAllocator &other [[maybe_unused]]) { } @@ -81,7 +81,7 @@ public: Free(static_cast(p)); } - template + template void construct(U *p, Args &&... args) // NOLINT(readability-identifier-naming) { if (p == nullptr) { @@ -89,7 +89,7 @@ public: } ::new (static_cast(p)) U(std::forward(args)...); } - template + template void destroy(U *p) // NOLINT(readability-identifier-naming) { if (p == nullptr) { @@ -113,7 +113,7 @@ public: return ptr; } - template + template [[nodiscard]] S *New(Args &&... args) { auto p = reinterpret_cast(Allocate(sizeof(S))); @@ -121,7 +121,7 @@ public: return reinterpret_cast(p); } - template + template void Finalize(S *ptr) { ASSERT(ptr != nullptr); diff --git a/runtime/mem/chunk.h b/runtime/mem/chunk.h index d831f6f8d..db033fd4f 100644 --- a/runtime/mem/chunk.h +++ b/runtime/mem/chunk.h @@ -52,13 +52,13 @@ public: return reinterpret_cast(result); } - template + template [[nodiscard]] T *NewArray(size_t size) { return static_cast(Allocate(size * sizeof(T))); } - template + template [[nodiscard]] T *New(Args &&... args) { auto p = reinterpret_cast(Allocate(sizeof(T))); @@ -66,7 +66,7 @@ public: return reinterpret_cast(p); } - template + template void Delete(T *ptr) { ASSERT(ptr != nullptr); @@ -87,12 +87,12 @@ private: Area *NewArea(size_t size); void ReleaseMemory(); - uintptr_t ptr_{0}; - uintptr_t end_{0}; + uintptr_t ptr_ {0}; + uintptr_t end_ {0}; - Area *currentArea_{nullptr}; - EcmaList areaList_{}; - RegionFactory *factory_{nullptr}; + Area *currentArea_ {nullptr}; + EcmaList areaList_ {}; + RegionFactory *factory_ {nullptr}; }; } // namespace panda::ecmascript diff --git a/runtime/mem/chunk_allocator.h b/runtime/mem/chunk_allocator.h index f2f072155..69da46a4f 100644 --- a/runtime/mem/chunk_allocator.h +++ b/runtime/mem/chunk_allocator.h @@ -19,7 +19,7 @@ #include "plugins/ecmascript/runtime/mem/chunk.h" namespace panda::ecmascript { -template +template class ChunkAllocator { public: // used for std allocator @@ -31,21 +31,21 @@ public: using size_type = size_t; using difference_type = ptrdiff_t; - template + template struct Rebind { using other = ChunkAllocator; }; - template + template using rebind = Rebind; explicit ChunkAllocator(Chunk *chunk) : chunk_(chunk) {} - template + template explicit ChunkAllocator(const ChunkAllocator &other) : chunk_(other.chunk_) { } - template + template friend class ChunkAllocator; ChunkAllocator(const ChunkAllocator &) = default; @@ -90,12 +90,12 @@ public: // NOLINTNEXTLINE(readability-identifier-naming) void deallocate([[maybe_unused]] pointer p, [[maybe_unused]] size_type n) {} - template + template void construct(U *p, Args &&... args) // NOLINT(readability-identifier-naming) { ::new (static_cast(p)) U(std::forward(args)...); } - template + template void destroy(U *p) // NOLINT(readability-identifier-naming) { if (p == nullptr) { diff --git a/runtime/mem/chunk_containers.h b/runtime/mem/chunk_containers.h index 85bc5f271..d5b39e8dc 100644 --- a/runtime/mem/chunk_containers.h +++ b/runtime/mem/chunk_containers.h @@ -31,7 +31,7 @@ #include "plugins/ecmascript/runtime/mem/chunk_allocator.h" namespace panda::ecmascript { -template +template class ChunkVector : public std::vector> { public: explicit ChunkVector(Chunk *chunk) : std::vector>(ChunkAllocator(chunk)) {} @@ -47,7 +47,7 @@ public: NO_MOVE_SEMANTIC(ChunkVector); }; -template> +template > class ChunkMap : public std::map>> { public: // Constructs an empty map. @@ -61,7 +61,7 @@ public: NO_MOVE_SEMANTIC(ChunkMap); }; -template, typename KeyEqual = std::equal_to> +template , typename KeyEqual = std::equal_to> class ChunkUnorderedMap : public std::unordered_map>> { public: // NOLINTNEXTLINE(readability-magic-numbers) @@ -75,7 +75,7 @@ public: NO_MOVE_SEMANTIC(ChunkUnorderedMap); }; -template> +template > class ChunkMultimap : public std::multimap>> { public: // Constructs an empty multimap. diff --git a/runtime/mem/clock_scope.h b/runtime/mem/clock_scope.h index d3baeacb9..ce0a32837 100644 --- a/runtime/mem/clock_scope.h +++ b/runtime/mem/clock_scope.h @@ -22,8 +22,8 @@ namespace panda::ecmascript { class ClockScope { -using Clock = std::chrono::high_resolution_clock; -using Duration = std::chrono::duration; + using Clock = std::chrono::high_resolution_clock; + using Duration = std::chrono::duration; public: explicit ClockScope() diff --git a/runtime/mem/compress_collector.cpp b/runtime/mem/compress_collector.cpp index e1eff4d6e..1c3c89972 100644 --- a/runtime/mem/compress_collector.cpp +++ b/runtime/mem/compress_collector.cpp @@ -28,8 +28,7 @@ #include "plugins/ecmascript/runtime/vmstat/runtime_stat.h" namespace panda::ecmascript { -CompressCollector::CompressCollector(Heap *heap) - : heap_(heap), workList_(heap->GetWorkList()) {} +CompressCollector::CompressCollector(Heap *heap) : heap_(heap), workList_(heap->GetWorkList()) {} void CompressCollector::RunPhases() { @@ -94,7 +93,7 @@ void CompressCollector::SweepPhases() { ECMA_BYTRACE_NAME(BYTRACE_TAG_ARK, "CompressCollector::SweepPhases"); // process weak reference - auto totalThreadCount = Platform::GetCurrentPlatform()->GetTotalThreadNum() + 1; // gc thread and main thread + auto totalThreadCount = Platform::GetCurrentPlatform()->GetTotalThreadNum() + 1; // gc thread and main thread for (uint32_t i = 0; i < totalThreadCount; i++) { ProcessQueue *queue = workList_->GetWeakReferenceQueue(i); diff --git a/runtime/mem/concurrent_marker.cpp b/runtime/mem/concurrent_marker.cpp index bf62a2ba6..9518c2871 100644 --- a/runtime/mem/concurrent_marker.cpp +++ b/runtime/mem/concurrent_marker.cpp @@ -28,10 +28,7 @@ namespace panda::ecmascript { ConcurrentMarker::ConcurrentMarker(Heap *heap) - : heap_(heap), - vm_(heap->GetEcmaVM()), - thread_(vm_->GetJSThread()), - workList_(heap->GetWorkList()) + : heap_(heap), vm_(heap->GetEcmaVM()), thread_(vm_->GetJSThread()), workList_(heap->GetWorkList()) { } @@ -67,7 +64,7 @@ void ConcurrentMarker::FinishPhase() void ConcurrentMarker::ReMarking() { ECMA_GC_LOG() << "ConcurrentMarker: Remarking Begin"; - Marker *nonMoveMarker = heap_->GetNonMovableMarker(); + Marker *nonMoveMarker = heap_->GetNonMovableMarker(); nonMoveMarker->MarkRoots(0); if (heap_->IsSemiMarkNeeded() && !heap_->IsParallelGCEnabled()) { heap_->GetNonMovableMarker()->ProcessOldToNew(0); @@ -128,13 +125,9 @@ void ConcurrentMarker::InitializeMarking() region->SetMarking(true); }); if (heap_->IsSemiMarkNeeded()) { - heap_->EnumerateNewSpaceRegions([](Region *current) { - current->ResetAliveObject(); - }); + heap_->EnumerateNewSpaceRegions([](Region *current) { current->ResetAliveObject(); }); } else { - heap_->EnumerateRegions([](Region *current) { - current->ResetAliveObject(); - }); + heap_->EnumerateRegions([](Region *current) { current->ResetAliveObject(); }); } workList_->Initialize(TriggerGCType::OLD_GC, ParallelGCTaskPhase::CONCURRENT_HANDLE_GLOBAL_POOL_TASK); heap_->GetNonMovableMarker()->MarkRoots(0); diff --git a/runtime/mem/concurrent_marker.h b/runtime/mem/concurrent_marker.h index 10216640a..cc5283a26 100644 --- a/runtime/mem/concurrent_marker.h +++ b/runtime/mem/concurrent_marker.h @@ -38,7 +38,7 @@ public: void FinishPhase(); void ReMarking(); - void HandleMarkFinished(); // call in vm thread. + void HandleMarkFinished(); // call in vm thread. void WaitConcurrentMarkingFinished(); // call in main thread void Reset(bool isClearCSet = true); @@ -86,8 +86,8 @@ private: size_t heapObjectSize_ {0}; double duration_ {0.0}; - bool notifyMarkingFinished_ {false}; // notify js-thread that marking is finished and need sweep - bool vmThreadWaitMarkingFinished_ {false}; // jsMainThread waiting for concurrentGC FINISHED + bool notifyMarkingFinished_ {false}; // notify js-thread that marking is finished and need sweep + bool vmThreadWaitMarkingFinished_ {false}; // jsMainThread waiting for concurrentGC FINISHED os::memory::Mutex waitMarkingFinishedMutex_; os::memory::ConditionVariable waitMarkingFinishedCV_; }; diff --git a/runtime/mem/concurrent_sweeper.cpp b/runtime/mem/concurrent_sweeper.cpp index ebe2bbcf3..33ad87c97 100644 --- a/runtime/mem/concurrent_sweeper.cpp +++ b/runtime/mem/concurrent_sweeper.cpp @@ -24,8 +24,7 @@ #include "plugins/ecmascript/runtime/platform/platform.h" namespace panda::ecmascript { -ConcurrentSweeper::ConcurrentSweeper(Heap *heap, bool concurrentSweep) - : heap_(heap), concurrentSweep_(concurrentSweep) +ConcurrentSweeper::ConcurrentSweeper(Heap *heap, bool concurrentSweep) : heap_(heap), concurrentSweep_(concurrentSweep) { } @@ -34,14 +33,12 @@ void ConcurrentSweeper::SweepPhases(bool compressGC) if (concurrentSweep_) { // Add all region to region list. Ensure all task finish if (!compressGC) { - heap_->GetOldSpace()->EnumerateNonCollectRegionSet([this](Region *current) { - AddRegion(OLD_SPACE, current); - }); + heap_->GetOldSpace()->EnumerateNonCollectRegionSet( + [this](Region *current) { AddRegion(OLD_SPACE, current); }); } heap_->GetNonMovableSpace()->EnumerateRegions([this](Region *current) { AddRegion(NON_MOVABLE, current); }); - heap_->GetMachineCodeSpace()->EnumerateRegions([this](Region *current) { - AddRegion(MACHINE_CODE_SPACE, current); - }); + heap_->GetMachineCodeSpace()->EnumerateRegions( + [this](Region *current) { AddRegion(MACHINE_CODE_SPACE, current); }); // Prepare isSweeping_ = true; @@ -64,8 +61,8 @@ void ConcurrentSweeper::SweepPhases(bool compressGC) Platform::GetCurrentPlatform()->PostTask(std::make_unique(this, MACHINE_CODE_SPACE)); } else { if (!compressGC) { - SweepSpace(OLD_SPACE, - const_cast(heap_->GetOldSpace()), heap_->GetHeapManager()->GetOldSpaceAllocator()); + SweepSpace(OLD_SPACE, const_cast(heap_->GetOldSpace()), + heap_->GetHeapManager()->GetOldSpaceAllocator()); canSelectCset_ = true; } else { canSelectCset_ = false; @@ -104,13 +101,9 @@ void ConcurrentSweeper::SweepSpace(MemSpaceType type, Space *space, FreeListAllo allocator.RebuildFreeList(); if (type == OLD_SPACE) { auto *oldSpace = static_cast(space); - oldSpace->EnumerateNonCollectRegionSet([this, &allocator](Region *current) { - FreeRegion(current, allocator); - }); + oldSpace->EnumerateNonCollectRegionSet([this, &allocator](Region *current) { FreeRegion(current, allocator); }); } else { - space->EnumerateRegions([this, &allocator](Region *current) { - FreeRegion(current, allocator); - }); + space->EnumerateRegions([this, &allocator](Region *current) { FreeRegion(current, allocator); }); } } diff --git a/runtime/mem/concurrent_sweeper.h b/runtime/mem/concurrent_sweeper.h index 014118a3c..bbaca4486 100644 --- a/runtime/mem/concurrent_sweeper.h +++ b/runtime/mem/concurrent_sweeper.h @@ -74,7 +74,7 @@ private: void FreeRegion(Region *current, FreeListAllocator &allocator, bool isMain = true); void FreeLiveRange(FreeListAllocator &allocator, Region *current, uintptr_t freeStart, uintptr_t freeEnd, - bool isMain); + bool isMain); void AddRegion(MemSpaceType type, Region *region); Region *GetRegionSafe(MemSpaceType type); diff --git a/runtime/mem/ecma_list.h b/runtime/mem/ecma_list.h index 481059071..b7da121e0 100644 --- a/runtime/mem/ecma_list.h +++ b/runtime/mem/ecma_list.h @@ -22,7 +22,7 @@ namespace panda::ecmascript { // Invoking std::list will cause cross invoking, which is time-consuming. // Therefore, we implement ecma list inside the vm. -template +template class EcmaList { public: EcmaList() : first_(nullptr), last_(nullptr) {} @@ -148,7 +148,7 @@ public: private: T *first_; T *last_; - uint32_t length_{0}; + uint32_t length_ {0}; }; } // namespace panda::ecmascript diff --git a/runtime/mem/evacuation_allocator.h b/runtime/mem/evacuation_allocator.h index 6b794f534..309c0cd79 100644 --- a/runtime/mem/evacuation_allocator.h +++ b/runtime/mem/evacuation_allocator.h @@ -58,13 +58,15 @@ public: private: class AsyncFreeRegionTask : public Task { public: - AsyncFreeRegionTask(EvacuationAllocator *allocator, TriggerGCType type) - : allocator_(allocator), gcType_(type) {} + AsyncFreeRegionTask(EvacuationAllocator *allocator, TriggerGCType type) : allocator_(allocator), gcType_(type) + { + } ~AsyncFreeRegionTask() override = default; bool Run(uint32_t threadIndex) override; NO_COPY_SEMANTIC(AsyncFreeRegionTask); NO_MOVE_SEMANTIC(AsyncFreeRegionTask); + private: EvacuationAllocator *allocator_; TriggerGCType gcType_; diff --git a/runtime/mem/free_object_list.cpp b/runtime/mem/free_object_list.cpp index bf0a1684e..4a1480b47 100644 --- a/runtime/mem/free_object_list.cpp +++ b/runtime/mem/free_object_list.cpp @@ -21,8 +21,9 @@ #include "plugins/ecmascript/runtime/mem/mem.h" namespace panda::ecmascript { -FreeObjectList::FreeObjectList() : kinds_(new FreeObjectKind *[NUMBER_OF_KINDS](), NUMBER_OF_KINDS), - lastKinds_(new FreeObjectKind *[NUMBER_OF_KINDS](), NUMBER_OF_KINDS) +FreeObjectList::FreeObjectList() + : kinds_(new FreeObjectKind *[NUMBER_OF_KINDS](), NUMBER_OF_KINDS), + lastKinds_(new FreeObjectKind *[NUMBER_OF_KINDS](), NUMBER_OF_KINDS) { for (int i = 0; i < NUMBER_OF_KINDS; i++) { kinds_[i] = nullptr; @@ -52,7 +53,7 @@ FreeObject *FreeObjectList::Allocator(size_t size) KindType lastType = type - 1; for (type = CalcNextNoneEmptyIndex(type); type > lastType && type < NUMBER_OF_KINDS; - type = CalcNextNoneEmptyIndex(type + 1)) { + type = CalcNextNoneEmptyIndex(type + 1)) { lastType = type; FreeObjectKind *current = kinds_[type]; while (current != nullptr) { @@ -200,7 +201,7 @@ void FreeObjectList::Merge(FreeObjectList *list) list->Rebuild(); } -template +template void FreeObjectList::EnumerateKinds(const Callback &cb) const { for (KindType i = 0; i < NUMBER_OF_KINDS; i++) { @@ -208,7 +209,7 @@ void FreeObjectList::EnumerateKinds(const Callback &cb) const } } -template +template void FreeObjectList::EnumerateKinds(KindType type, const Callback &cb) const { FreeObjectKind *current = kinds_[type]; @@ -220,7 +221,7 @@ void FreeObjectList::EnumerateKinds(KindType type, const Callback &cb) const } } -template +template void FreeObjectList::EnumerateTopAndLastKinds(const Callback &cb) const { for (KindType i = 0; i < NUMBER_OF_KINDS; i++) { diff --git a/runtime/mem/free_object_list.h b/runtime/mem/free_object_list.h index bccd18e0f..84227ef6e 100644 --- a/runtime/mem/free_object_list.h +++ b/runtime/mem/free_object_list.h @@ -39,13 +39,13 @@ public: void Merge(FreeObjectList *list); - template + template void EnumerateKinds(const Callback &cb) const; - template + template void EnumerateKinds(KindType type, const Callback &cb) const; - template + template void EnumerateTopAndLastKinds(const Callback &cb) const; NO_COPY_SEMANTIC(FreeObjectList); diff --git a/runtime/mem/heap-inl.h b/runtime/mem/heap-inl.h index d1430c141..84c3d490b 100644 --- a/runtime/mem/heap-inl.h +++ b/runtime/mem/heap-inl.h @@ -26,7 +26,7 @@ #include "plugins/ecmascript/runtime/mem/remembered_set.h" namespace panda::ecmascript { -template +template void Heap::EnumerateOldSpaceRegions(const Callback &cb, Region *region) const { oldSpace_->EnumerateRegions(cb, region); @@ -35,19 +35,19 @@ void Heap::EnumerateOldSpaceRegions(const Callback &cb, Region *region) const machineCodeSpace_->EnumerateRegions(cb); } -template +template void Heap::EnumerateSnapShotSpaceRegions(const Callback &cb) const { snapshotSpace_->EnumerateRegions(cb); } -template +template void Heap::EnumerateNewSpaceRegions(const Callback &cb) const { toSpace_->EnumerateRegions(cb); } -template +template void Heap::EnumerateNonMovableRegions(const Callback &cb) const { snapshotSpace_->EnumerateRegions(cb); @@ -56,7 +56,7 @@ void Heap::EnumerateNonMovableRegions(const Callback &cb) const machineCodeSpace_->EnumerateRegions(cb); } -template +template void Heap::EnumerateRegions(const Callback &cb) const { toSpace_->EnumerateRegions(cb); @@ -67,7 +67,7 @@ void Heap::EnumerateRegions(const Callback &cb) const machineCodeSpace_->EnumerateRegions(cb); } -template +template void Heap::IteratorOverObjects(const Callback &cb) const { toSpace_->IterateOverObjects(cb); @@ -84,10 +84,10 @@ bool Heap::FillNewSpaceAndTryGC(BumpPointerAllocator *spaceAllocator, bool allow return true; } - if (toSpace_->GetCommittedSize() == SEMI_SPACE_SIZE_CAPACITY - && !GetEcmaVM()->GetAssociatedJSThread()->IsReadyToMark()) { - toSpace_->SetMaximumCapacity(std::min(SEMI_SPACE_SIZE_CAPACITY + SEMI_SPACE_OVERSHOOT_SIZE, - MAX_SEMI_SPACE_SIZE_STARTUP)); + if (toSpace_->GetCommittedSize() == SEMI_SPACE_SIZE_CAPACITY && + !GetEcmaVM()->GetAssociatedJSThread()->IsReadyToMark()) { + toSpace_->SetMaximumCapacity( + std::min(SEMI_SPACE_SIZE_CAPACITY + SEMI_SPACE_OVERSHOOT_SIZE, MAX_SEMI_SPACE_SIZE_STARTUP)); if (toSpace_->Expand(spaceAllocator->GetTop())) { spaceAllocator->Reset(toSpace_); return true; @@ -255,16 +255,17 @@ void Heap::ClearSlotsRange(Region *current, uintptr_t freeStart, uintptr_t freeE size_t Heap::GetCommittedSize() const { - size_t result = toSpace_->GetCommittedSize() + oldSpace_->GetCommittedSize() + hugeObjectSpace_->GetCommittedSize() - + nonMovableSpace_->GetCommittedSize() + machineCodeSpace_->GetCommittedSize(); + size_t result = toSpace_->GetCommittedSize() + oldSpace_->GetCommittedSize() + + hugeObjectSpace_->GetCommittedSize() + nonMovableSpace_->GetCommittedSize() + + machineCodeSpace_->GetCommittedSize(); return result; } size_t Heap::GetHeapObjectSize() const { - size_t result = toSpace_->GetHeapObjectSize() + oldSpace_->GetHeapObjectSize() - + hugeObjectSpace_->GetHeapObjectSize() + nonMovableSpace_->GetHeapObjectSize() - + machineCodeSpace_->GetCommittedSize(); + size_t result = toSpace_->GetHeapObjectSize() + oldSpace_->GetHeapObjectSize() + + hugeObjectSpace_->GetHeapObjectSize() + nonMovableSpace_->GetHeapObjectSize() + + machineCodeSpace_->GetCommittedSize(); return result; } } // namespace panda::ecmascript diff --git a/runtime/mem/machine_code.h b/runtime/mem/machine_code.h index 8605f94c8..e1250ab26 100644 --- a/runtime/mem/machine_code.h +++ b/runtime/mem/machine_code.h @@ -50,8 +50,8 @@ public: LOG_ECMA_MEM(ERROR) << "data is null in creating new code object"; return; } - if (memcpy_s(reinterpret_cast(this->GetDataOffsetAddress()), - this->GetInstructionSizeInBytes().GetInt(), stackMapData, codeLength) != EOK) { + if (memcpy_s(reinterpret_cast(this->GetDataOffsetAddress()), this->GetInstructionSizeInBytes().GetInt(), + stackMapData, codeLength) != EOK) { LOG_ECMA_MEM(ERROR) << "memcpy fail in creating new code object "; return; } diff --git a/runtime/mem/mark_stack-inl.h b/runtime/mem/mark_stack-inl.h index 11cb4e9d4..a83e6450f 100644 --- a/runtime/mem/mark_stack-inl.h +++ b/runtime/mem/mark_stack-inl.h @@ -20,7 +20,7 @@ #include "plugins/ecmascript/runtime/mem/region_factory.h" namespace panda::ecmascript { -template +template void ContinuousStack::BeginMarking(Heap *heap, ContinuousStack *other) { heap_ = heap; @@ -31,7 +31,7 @@ void ContinuousStack::BeginMarking(Heap *heap, ContinuousStack *other) ResetBegin(currentArea_->GetBegin(), currentArea_->GetEnd()); } -template +template void ContinuousStack::FinishMarking(ContinuousStack *other) { other->currentArea_ = currentArea_; @@ -42,7 +42,7 @@ void ContinuousStack::FinishMarking(ContinuousStack *other) } } -template +template void ContinuousStack::Extend() { auto area = RegionFactory::AllocateSpace(DEFAULT_MARK_STACK_SIZE); @@ -51,7 +51,7 @@ void ContinuousStack::Extend() ResetBegin(currentArea_->GetBegin(), currentArea_->GetEnd()); } -template +template void ContinuousStack::Destroy() { if (currentArea_ != nullptr) { diff --git a/runtime/mem/mark_stack.h b/runtime/mem/mark_stack.h index 2cec86021..ec0b6c187 100644 --- a/runtime/mem/mark_stack.h +++ b/runtime/mem/mark_stack.h @@ -85,15 +85,15 @@ public: } private: - template + template friend class ContinuousStack; friend class WorkNode; - uintptr_t begin_{0}; - uintptr_t *end_{nullptr}; - uintptr_t *top_{nullptr}; + uintptr_t begin_ {0}; + uintptr_t *end_ {nullptr}; + uintptr_t *top_ {nullptr}; }; -template +template class ContinuousStack : public Stack { public: ContinuousStack() = default; @@ -133,10 +133,10 @@ public: private: inline void Extend(); - Heap *heap_{nullptr}; - Area *currentArea_{nullptr}; - EcmaList areaList_{}; - EcmaList unusedList_{}; + Heap *heap_ {nullptr}; + Area *currentArea_ {nullptr}; + EcmaList areaList_ {}; + EcmaList unusedList_ {}; }; using MarkStack = ContinuousStack; diff --git a/runtime/mem/mark_word.h b/runtime/mem/mark_word.h index a6bc442ce..eb830dc22 100644 --- a/runtime/mem/mark_word.h +++ b/runtime/mem/mark_word.h @@ -68,7 +68,7 @@ public: } private: - MarkWordType value_{0}; + MarkWordType value_ {0}; }; } // namespace ecmascript } // namespace panda diff --git a/runtime/mem/mem.h b/runtime/mem/mem.h index f2279707f..d403a77f8 100644 --- a/runtime/mem/mem.h +++ b/runtime/mem/mem.h @@ -96,13 +96,13 @@ static constexpr size_t MAX_CHUNK_AREA_SIZE = 1 * 1024 * 1024; static constexpr uintptr_t PANDA_32BITS_HEAP_START_ADDRESS_256 = 256_KB; static constexpr double SEMI_SPACE_RETENTION_RATIO = 0.75; -template +template constexpr inline bool IsAligned(T value, size_t alignment) { return (value & (alignment - 1U)) == 0; } -template +template inline T AlignDown(T x, size_t alignment) { ASSERT(std::is_integral::value); @@ -111,7 +111,7 @@ inline T AlignDown(T x, size_t alignment) return x & ~(alignment - 1U); } -template +template inline T AlignUp(T x, size_t alignment) { ASSERT(std::is_integral::value); diff --git a/runtime/mem/mem_manager.cpp b/runtime/mem/mem_manager.cpp index 142a4d36b..15614ed37 100644 --- a/runtime/mem/mem_manager.cpp +++ b/runtime/mem/mem_manager.cpp @@ -20,8 +20,8 @@ namespace panda::ecmascript { MemManager::MemManager(Heap *heap) : heap_(heap), newSpaceAllocator_(heap->GetNewSpace()), - freeListAllocator_ { FreeListAllocator(heap->GetOldSpace()), FreeListAllocator(heap_->GetNonMovableSpace()), - FreeListAllocator(heap->GetMachineCodeSpace()) } + freeListAllocator_ {FreeListAllocator(heap->GetOldSpace()), FreeListAllocator(heap_->GetNonMovableSpace()), + FreeListAllocator(heap->GetMachineCodeSpace())} { ASSERT(heap != nullptr); heap->SetHeapManager(this); diff --git a/runtime/mem/mix_space_collector.cpp b/runtime/mem/mix_space_collector.cpp index 1cdd249e6..e16095a7e 100644 --- a/runtime/mem/mix_space_collector.cpp +++ b/runtime/mem/mix_space_collector.cpp @@ -48,8 +48,8 @@ void MixSpaceCollector::RunPhases() SweepPhases(); heap_->GetEvacuation()->Finalize(); FinishPhase(); - heap_->GetEcmaVM()->GetEcmaGCStats()->StatisticOldCollector( - clockScope.GetPauseTime(), freeSize_, oldSpaceCommitSize_, nonMoveSpaceCommitSize_); + heap_->GetEcmaVM()->GetEcmaGCStats()->StatisticOldCollector(clockScope.GetPauseTime(), freeSize_, + oldSpaceCommitSize_, nonMoveSpaceCommitSize_); ECMA_GC_LOG() << "MixSpaceCollector::RunPhases " << clockScope.TotalSpentTime(); } @@ -76,13 +76,9 @@ void MixSpaceCollector::InitializePhase() current->SetMarking(false); }); if (heap_->IsSemiMarkNeeded()) { - heap_->EnumerateNewSpaceRegions([](Region *current) { - current->ResetAliveObject(); - }); + heap_->EnumerateNewSpaceRegions([](Region *current) { current->ResetAliveObject(); }); } else { - heap_->EnumerateRegions([](Region *current) { - current->ResetAliveObject(); - }); + heap_->EnumerateRegions([](Region *current) { current->ResetAliveObject(); }); } workList_->Initialize(TriggerGCType::OLD_GC, ParallelGCTaskPhase::OLD_HANDLE_GLOBAL_POOL_TASK); @@ -102,9 +98,7 @@ void MixSpaceCollector::FinishPhase() } else { size_t aliveSize = 0; workList_->Finish(aliveSize); - heap_->EnumerateRegions([](Region *current) { - current->ClearFlag(RegionFlags::IS_IN_PROMOTE_SET); - }); + heap_->EnumerateRegions([](Region *current) { current->ClearFlag(RegionFlags::IS_IN_PROMOTE_SET); }); } } diff --git a/runtime/mem/object_xray-inl.h b/runtime/mem/object_xray-inl.h index 16aae1064..004be244a 100644 --- a/runtime/mem/object_xray-inl.h +++ b/runtime/mem/object_xray-inl.h @@ -70,7 +70,7 @@ void ObjectXRay::VisitVMRoots(const RootVisitor &visitor, const RootRangeVisitor ecmaVm_->GetJSThread()->Iterate(visitor, range_visitor); } -template +template // NOLINTNEXTLINE(readability-function-size) void ObjectXRay::VisitObjectBody(TaggedObject *object, JSHClass *klass, const EcmaObjectRangeVisitor &visitor) { diff --git a/runtime/mem/object_xray.h b/runtime/mem/object_xray.h index ddbadd33c..9fe7bc375 100644 --- a/runtime/mem/object_xray.h +++ b/runtime/mem/object_xray.h @@ -48,7 +48,7 @@ public: ~ObjectXRay() = default; inline void VisitVMRoots(const RootVisitor &visitor, const RootRangeVisitor &range_visitor) const; - template + template inline void VisitObjectBody(TaggedObject *object, JSHClass *klass, const EcmaObjectRangeVisitor &visitor); DEFAULT_MOVE_SEMANTIC(ObjectXRay); diff --git a/runtime/mem/parallel_marker.cpp b/runtime/mem/parallel_marker.cpp index c210b215e..928ed0a9b 100644 --- a/runtime/mem/parallel_marker.cpp +++ b/runtime/mem/parallel_marker.cpp @@ -24,10 +24,9 @@ Marker::Marker(Heap *heap) : heap_(heap), objXRay_(heap_->GetEcmaVM()) {} void Marker::MarkRoots(uint32_t threadId) { - objXRay_.VisitVMRoots( - std::bind(&Marker::HandleRoots, this, threadId, std::placeholders::_1, std::placeholders::_2), - std::bind(&Marker::HandleRangeRoots, this, threadId, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + objXRay_.VisitVMRoots(std::bind(&Marker::HandleRoots, this, threadId, std::placeholders::_1, std::placeholders::_2), + std::bind(&Marker::HandleRangeRoots, this, threadId, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3)); heap_->GetWorkList()->PushWorkNodeToGlobal(threadId, false); } @@ -67,9 +66,9 @@ void NonMovableMarker::ProcessMarkStack(uint32_t threadId) Region *objectRegion = Region::ObjectAddressToRange(obj); bool needBarrier = !isOnlySemi && !objectRegion->InYoungAndCSetGeneration(); objXRay_.VisitObjectBody(obj, jsHclass, - std::bind(&Marker::HandleObjectVisitor, this, threadId, - objectRegion, needBarrier, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3)); + std::bind(&Marker::HandleObjectVisitor, this, threadId, objectRegion, + needBarrier, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } } @@ -92,9 +91,9 @@ void SemiGcMarker::ProcessMarkStack(uint32_t threadId) Region *objectRegion = Region::ObjectAddressToRange(obj); bool promoted = !objectRegion->InYoungGeneration(); objXRay_.VisitObjectBody(obj, jsHclass, - std::bind(&Marker::HandleMoveObjectVisitor, this, threadId, - promoted, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + std::bind(&Marker::HandleMoveObjectVisitor, this, threadId, promoted, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } } @@ -113,9 +112,9 @@ void CompressGcMarker::ProcessMarkStack(uint32_t threadId) MarkObject(threadId, jsHclass, objectSlot); objXRay_.VisitObjectBody(obj, jsHclass, - std::bind(&Marker::HandleMoveObjectVisitor, this, threadId, false, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + std::bind(&Marker::HandleMoveObjectVisitor, this, threadId, false, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)); } } } // namespace panda::ecmascript diff --git a/runtime/mem/parallel_marker.h b/runtime/mem/parallel_marker.h index e21d89c0c..f01b9730c 100644 --- a/runtime/mem/parallel_marker.h +++ b/runtime/mem/parallel_marker.h @@ -89,8 +89,7 @@ protected: void ProcessMarkStack(uint32_t threadId) override; void MarkObject(uint32_t threadId, TaggedObject *object) override; void HandleRoots(uint32_t threadId, [[maybe_unused]] Root type, ObjectSlot slot) override; - void HandleRangeRoots(uint32_t threadId, [[maybe_unused]] Root type, ObjectSlot start, - ObjectSlot end) override; + void HandleRangeRoots(uint32_t threadId, [[maybe_unused]] Root type, ObjectSlot start, ObjectSlot end) override; void HandleOldToNewRSet(uint32_t threadId, Region *region) override; void RecordWeakReference(uint32_t threadId, JSTaggedType *ref) override; @@ -102,8 +101,7 @@ public: protected: void HandleRoots(uint32_t threadId, [[maybe_unused]] Root type, ObjectSlot slot) override; - void HandleRangeRoots(uint32_t threadId, [[maybe_unused]] Root type, ObjectSlot start, - ObjectSlot end) override; + void HandleRangeRoots(uint32_t threadId, [[maybe_unused]] Root type, ObjectSlot start, ObjectSlot end) override; virtual inline SlotStatus EvacuateObject(uint32_t threadId, TaggedObject *object, const MarkWord &markWord, ObjectSlot slot) = 0; @@ -127,7 +125,7 @@ protected: void ProcessMarkStack(uint32_t threadId) override; SlotStatus MarkObject(uint32_t threadId, TaggedObject *object, ObjectSlot slot) override; SlotStatus EvacuateObject(uint32_t threadId, TaggedObject *object, const MarkWord &markWord, - ObjectSlot slot) override; + ObjectSlot slot) override; void RecordWeakReference(uint32_t threadId, JSTaggedType *ref) override; private: @@ -145,7 +143,7 @@ protected: SlotStatus MarkObject(uint32_t threadId, TaggedObject *object, ObjectSlot slot) override; SlotStatus EvacuateObject(uint32_t threadId, TaggedObject *object, const MarkWord &markWord, - ObjectSlot slot) override; + ObjectSlot slot) override; void RecordWeakReference(uint32_t threadId, JSTaggedType *ref) override; }; } // namespace panda::ecmascript diff --git a/runtime/mem/parallel_work_helper.cpp b/runtime/mem/parallel_work_helper.cpp index df32528e2..7628f581c 100644 --- a/runtime/mem/parallel_work_helper.cpp +++ b/runtime/mem/parallel_work_helper.cpp @@ -114,8 +114,8 @@ void WorkerHelper::Finish(size_t &aliveSize) } while (!unuseSpace_.empty()) { - const_cast(heap_->GetRegionFactory())->FreeBuffer(reinterpret_cast( - unuseSpace_.back())); + const_cast(heap_->GetRegionFactory()) + ->FreeBuffer(reinterpret_cast(unuseSpace_.back())); unuseSpace_.pop_back(); } } diff --git a/runtime/mem/parallel_work_helper.h b/runtime/mem/parallel_work_helper.h index 61062f22d..b62eeb016 100644 --- a/runtime/mem/parallel_work_helper.h +++ b/runtime/mem/parallel_work_helper.h @@ -205,14 +205,14 @@ private: Heap *heap_; uint32_t threadNum_; std::array workList_; - std::array *, MAX_PLATFORM_THREAD_NUM + 1> continuousQueue_{}; + std::array *, MAX_PLATFORM_THREAD_NUM + 1> continuousQueue_ {}; GlobalWorkList globalWork_; uintptr_t markSpace_; uintptr_t spaceTop_; uintptr_t markSpaceEnd_; std::vector unuseSpace_; os::memory::Mutex mtx_; - ParallelGCTaskPhase parallelTask_{}; + ParallelGCTaskPhase parallelTask_ {}; }; } // namespace panda::ecmascript #endif // ECMASCRIPT_MEM_PARALLEL_WORK_HELPER_H diff --git a/runtime/mem/region-inl.h b/runtime/mem/region-inl.h index 076c52d2f..cdcbca401 100644 --- a/runtime/mem/region-inl.h +++ b/runtime/mem/region-inl.h @@ -129,8 +129,7 @@ void Region::ClearCrossRegionRememberedSet() { if (crossRegionSet_ != nullptr) { auto size = RememberedSet::GetSizeInByte(GetCapacity()); - const_cast(heap_->GetRegionFactory())->Free( - crossRegionSet_->GetBitMap().Data(), size); + const_cast(heap_->GetRegionFactory())->Free(crossRegionSet_->GetBitMap().Data(), size); delete crossRegionSet_; crossRegionSet_ = nullptr; } @@ -140,8 +139,7 @@ void Region::ClearOldToNewRememberedSet() { if (oldToNewSet_ != nullptr) { auto size = RememberedSet::GetSizeInByte(GetCapacity()); - const_cast(heap_->GetRegionFactory())->Free( - oldToNewSet_->GetBitMap().Data(), size); + const_cast(heap_->GetRegionFactory())->Free(oldToNewSet_->GetBitMap().Data(), size); delete oldToNewSet_; oldToNewSet_ = nullptr; } diff --git a/runtime/mem/region.h b/runtime/mem/region.h index 8c2de222b..c1a0a9180 100644 --- a/runtime/mem/region.h +++ b/runtime/mem/region.h @@ -31,24 +31,25 @@ class WorkerHelper; enum RegionFlags : uint32_t { NEVER_EVACUATE = 1, - HAS_AGE_MARK = 1 << 1, // NOLINT(hicpp-signed-bitwise) - BELOW_AGE_MARK = 1 << 2, // NOLINT(hicpp-signed-bitwise) - IS_IN_YOUNG_GENERATION = 1 << 3, // NOLINT(hicpp-signed-bitwise) - IS_IN_SNAPSHOT_GENERATION = 1 << 4, // NOLINT(hicpp-signed-bitwise) - IS_HUGE_OBJECT = 1 << 5, // NOLINT(hicpp-signed-bitwise) - IS_IN_OLD_GENERATION = 1 << 6, // NOLINT(hicpp-signed-bitwise) - IS_IN_NON_MOVABLE_GENERATION = 1 << 7, // NOLINT(hicpp-signed-bitwise) + HAS_AGE_MARK = 1 << 1, // NOLINT(hicpp-signed-bitwise) + BELOW_AGE_MARK = 1 << 2, // NOLINT(hicpp-signed-bitwise) + IS_IN_YOUNG_GENERATION = 1 << 3, // NOLINT(hicpp-signed-bitwise) + IS_IN_SNAPSHOT_GENERATION = 1 << 4, // NOLINT(hicpp-signed-bitwise) + IS_HUGE_OBJECT = 1 << 5, // NOLINT(hicpp-signed-bitwise) + IS_IN_OLD_GENERATION = 1 << 6, // NOLINT(hicpp-signed-bitwise) + IS_IN_NON_MOVABLE_GENERATION = 1 << 7, // NOLINT(hicpp-signed-bitwise) IS_IN_YOUNG_OR_OLD_GENERATION = IS_IN_YOUNG_GENERATION | IS_IN_OLD_GENERATION, - IS_IN_COLLECT_SET = 1 << 8, // NOLINT(hicpp-signed-bitwise) - IS_IN_PROMOTE_SET = 1 << 9, // NOLINT(hicpp-signed-bitwise) + IS_IN_COLLECT_SET = 1 << 8, // NOLINT(hicpp-signed-bitwise) + IS_IN_PROMOTE_SET = 1 << 9, // NOLINT(hicpp-signed-bitwise) IS_IN_YOUNG_OR_CSET_GENERATION = IS_IN_YOUNG_GENERATION | IS_IN_COLLECT_SET, - IS_INVALID = 1 << 10, // NOLINT(hicpp-signed-bitwise) + IS_INVALID = 1 << 10, // NOLINT(hicpp-signed-bitwise) }; class Region { public: Region(Space *space, Heap *heap, uintptr_t allocateBase, uintptr_t begin, uintptr_t end) - : space_(space), heap_(heap), + : space_(space), + heap_(heap), flags_(0), allocateBase_(allocateBase), // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) @@ -276,7 +277,7 @@ public: return kinds_[type]; } - template + template void EnumerateKinds(Callback cb) { for (auto kind : kinds_) { diff --git a/runtime/mem/region_factory.cpp b/runtime/mem/region_factory.cpp index 047c65beb..d5ceff43f 100644 --- a/runtime/mem/region_factory.cpp +++ b/runtime/mem/region_factory.cpp @@ -158,12 +158,12 @@ void RegionFactory::FreeBuffer(void *mem) free(mem); } -void RegionFactory::FreeBufferFunc(void *buffer, void* data) +void RegionFactory::FreeBufferFunc(void *buffer, void *data) { if (buffer == nullptr || data == nullptr) { return; } - auto* factory = reinterpret_cast(data); + auto *factory = reinterpret_cast(data); factory->FreeBuffer(buffer); } } // namespace panda::ecmascript diff --git a/runtime/mem/region_factory.h b/runtime/mem/region_factory.h index 465a58592..dcd232a0d 100644 --- a/runtime/mem/region_factory.h +++ b/runtime/mem/region_factory.h @@ -46,10 +46,10 @@ public: void *AllocateBuffer(size_t size); void FreeBuffer(void *mem); - static void FreeBufferFunc(void* buffer, void* data); + static void FreeBufferFunc(void *buffer, void *data); // implemented by AllocateBuffer - template + template std::enable_if_t, T *> New(Args &&... args) { void *p = AllocateBuffer(sizeof(T)); @@ -60,7 +60,7 @@ public: return reinterpret_cast(p); } - template + template void Delete(T *ptr) { if (ptr == nullptr) { diff --git a/runtime/mem/remembered_set.h b/runtime/mem/remembered_set.h index 3059bcdf3..815575275 100644 --- a/runtime/mem/remembered_set.h +++ b/runtime/mem/remembered_set.h @@ -49,13 +49,13 @@ public: AtomicTestAndSetBit(AddrToBitOffset(address)); } - template + template void IterateOverSetBits(VisitorType visitor) { IterateOverSetBitsInRange(0, Size(), visitor); } - template + template void IterateOverMarkedChunks(MemVisitor visitor) { IterateOverSetBits( diff --git a/runtime/mem/semi_space_collector.h b/runtime/mem/semi_space_collector.h index 2ac14c26f..03cdb1910 100644 --- a/runtime/mem/semi_space_collector.h +++ b/runtime/mem/semi_space_collector.h @@ -62,8 +62,8 @@ private: inline void UpdatePromotedSlot(TaggedObject *object, ObjectSlot slot); Heap *heap_; - size_t promotedSize_{0}; - size_t semiCopiedSize_{0}; + size_t promotedSize_ {0}; + size_t semiCopiedSize_ {0}; size_t commitSize_ = 0; // obtain from heap diff --git a/runtime/mem/space-inl.h b/runtime/mem/space-inl.h index 107030095..068644498 100644 --- a/runtime/mem/space-inl.h +++ b/runtime/mem/space-inl.h @@ -19,7 +19,7 @@ #include "plugins/ecmascript/runtime/mem/space.h" namespace panda::ecmascript { -template +template void Space::EnumerateRegions(const Callback &cb, Region *end) const { Region *current = regionList_.GetFirst(); @@ -37,7 +37,7 @@ void Space::EnumerateRegions(const Callback &cb, Region *end) const } } -template +template void OldSpace::EnumerateCollectRegionSet(const Callback &cb) const { for (Region *current : collectRegionSet_) { @@ -48,7 +48,7 @@ void OldSpace::EnumerateCollectRegionSet(const Callback &cb) const } } -template +template void OldSpace::EnumerateNonCollectRegionSet(const Callback &cb) const { EnumerateRegions([&cb](Region *region) { diff --git a/runtime/mem/space.cpp b/runtime/mem/space.cpp index 8ed18a659..a912ece7d 100644 --- a/runtime/mem/space.cpp +++ b/runtime/mem/space.cpp @@ -77,7 +77,7 @@ void Space::Initialize() region->InitializeKind(); region->SetFlag(RegionFlags::IS_IN_NON_MOVABLE_GENERATION); // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) - [[maybe_unused]]int res = region->SetCodeExecutableAndReadable(); + [[maybe_unused]] int res = region->SetCodeExecutableAndReadable(); LOG_ECMA_MEM(DEBUG) << "Initialize SetCodeExecutableAndReadable" << res; } else if (spaceType_ == MemSpaceType::NON_MOVABLE) { region->InitializeKind(); @@ -617,7 +617,7 @@ bool MachineCodeSpace::Expand() region->SetMarking(true); } // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) - [[maybe_unused]]int res = region->SetCodeExecutableAndReadable(); + [[maybe_unused]] int res = region->SetCodeExecutableAndReadable(); LOG_ECMA_MEM(DEBUG) << "MachineCodeSpace::Expand() SetCodeExecutableAndReadable" << res; return true; } diff --git a/runtime/mem/space.h b/runtime/mem/space.h index 24737c138..7a28d3c34 100644 --- a/runtime/mem/space.h +++ b/runtime/mem/space.h @@ -249,8 +249,9 @@ public: { return std::max(committedSize_ / PARTIAL_GC_MAX_COLLECT_REGION_RATE, PARTIAL_GC_INITIAL_COLLECT_REGION_SIZE); } + private: - static constexpr size_t PARTIAL_GC_MAX_COLLECT_REGION_RATE = 1024 * 1024 * 2; + static constexpr size_t PARTIAL_GC_MAX_COLLECT_REGION_RATE = 1024 * 1024 * 2; static constexpr size_t PARTIAL_GC_INITIAL_COLLECT_REGION_SIZE = 16; static constexpr size_t PARTIAL_GC_MIN_COLLECT_REGION_SIZE = 5; CVector collectRegionSet_; diff --git a/runtime/mem/tagged_object.h b/runtime/mem/tagged_object.h index 531bf9d29..241c6cfb8 100644 --- a/runtime/mem/tagged_object.h +++ b/runtime/mem/tagged_object.h @@ -21,7 +21,7 @@ namespace panda::ecmascript { class JSHClass; -template +template class JSHandle; class JSThread; @@ -43,7 +43,7 @@ public: return sizeof(TaggedObject); } - JSThread* GetJSThread() const; + JSThread *GetJSThread() const; }; static_assert(TaggedObject::TaggedObjectSize() == sizeof(ObjectHeader)); } // namespace panda::ecmascript diff --git a/runtime/mem/tlab_allocator-inl.h b/runtime/mem/tlab_allocator-inl.h index d9b2e597e..23e88678c 100644 --- a/runtime/mem/tlab_allocator-inl.h +++ b/runtime/mem/tlab_allocator-inl.h @@ -72,7 +72,7 @@ uintptr_t TlabAllocator::TlabAllocatorYoungSpace(size_t size) { size = AlignUp(size, static_cast(MemAlignment::MEM_ALIGN_OBJECT)); if (UNLIKELY(size >= SMALL_OBJECT_SIZE)) { - uintptr_t address = allocator_->AllocateYoung(size); + uintptr_t address = allocator_->AllocateYoung(size); LOG(DEBUG, RUNTIME) << "AllocatorYoungSpace:" << address; return address; } @@ -96,7 +96,7 @@ uintptr_t TlabAllocator::TlabAllocatorOldSpace(size_t size) uintptr_t result = oldBumpPointerAllocator_.Allocate(size); if (result != 0) { FreeObject::FillFreeObject(heap_->GetEcmaVM(), oldBumpPointerAllocator_.GetTop(), - oldBumpPointerAllocator_.Available()); + oldBumpPointerAllocator_.Available()); return result; } Region *current = Region::ObjectAddressToRange(oldBumpPointerAllocator_.GetTop()); @@ -110,7 +110,7 @@ uintptr_t TlabAllocator::TlabAllocatorOldSpace(size_t size) result = oldBumpPointerAllocator_.Allocate(size); if (result != 0) { FreeObject::FillFreeObject(heap_->GetEcmaVM(), oldBumpPointerAllocator_.GetTop(), - oldBumpPointerAllocator_.Available()); + oldBumpPointerAllocator_.Available()); } return result; } @@ -137,7 +137,7 @@ bool TlabAllocator::ExpandOld() } oldBumpPointerAllocator_.Reset(buffer, buffer + YOUNG_BUFFER_SIZE); FreeObject::FillFreeObject(heap_->GetEcmaVM(), oldBumpPointerAllocator_.GetTop(), - oldBumpPointerAllocator_.Available()); + oldBumpPointerAllocator_.Available()); } else if (gcType_ == TriggerGCType::COMPRESS_FULL_GC) { Region *region = allocator_->ExpandOldSpace(); if (region == nullptr) { @@ -146,7 +146,7 @@ bool TlabAllocator::ExpandOld() region->SetAliveObject(region->GetSize()); oldBumpPointerAllocator_.Reset(region->GetBegin(), region->GetEnd()); FreeObject::FillFreeObject(heap_->GetEcmaVM(), oldBumpPointerAllocator_.GetTop(), - oldBumpPointerAllocator_.Available()); + oldBumpPointerAllocator_.Available()); } else { UNREACHABLE(); } diff --git a/runtime/mem/verification.h b/runtime/mem/verification.h index c72bc5f63..5a6c65bd3 100644 --- a/runtime/mem/verification.h +++ b/runtime/mem/verification.h @@ -47,8 +47,8 @@ public: private: void VisitAllObjects(TaggedObject *obj); - const Heap* const heap_ {nullptr}; - size_t* const failCount_ {nullptr}; + const Heap *const heap_ {nullptr}; + size_t *const failCount_ {nullptr}; ObjectXRay objXRay_; }; @@ -67,6 +67,7 @@ public: bool IsHeapAddress(void *addr) const; size_t VerifyRoot() const; size_t VerifyHeap() const; + private: NO_COPY_SEMANTIC(Verification); NO_MOVE_SEMANTIC(Verification); diff --git a/runtime/message_string.cpp b/runtime/message_string.cpp index a4f8b4cda..55e539154 100644 --- a/runtime/message_string.cpp +++ b/runtime/message_string.cpp @@ -26,7 +26,7 @@ static std::array g_messageString #undef DEF_MESSAGE_ID }; -const std::string& MessageString::GetMessageString(int id) +const std::string &MessageString::GetMessageString(int id) { ASSERT(id < MessageString::MAX_MESSAGE_COUNT); return g_messageString[id]; diff --git a/runtime/message_string.h b/runtime/message_string.h index 6b521c29e..77e4f98ad 100644 --- a/runtime/message_string.h +++ b/runtime/message_string.h @@ -36,7 +36,7 @@ public: #undef DEF_MESSAGE_ID MAX_MESSAGE_COUNT }; - static const std::string& GetMessageString(int id); + static const std::string &GetMessageString(int id); }; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/runtime/napi/jsnapi_helper-inl.h b/runtime/napi/jsnapi_helper-inl.h index 60647e4db..f1869e124 100644 --- a/runtime/napi/jsnapi_helper-inl.h +++ b/runtime/napi/jsnapi_helper-inl.h @@ -21,7 +21,7 @@ #include "libpandabase/macros.h" namespace panda { -template +template Local JSNApiHelper::ToLocal(ecmascript::JSHandle from) { return Local(from.GetAddress()); diff --git a/runtime/napi/jsnapi_helper.h b/runtime/napi/jsnapi_helper.h index cc5014d6c..b063b113a 100644 --- a/runtime/napi/jsnapi_helper.h +++ b/runtime/napi/jsnapi_helper.h @@ -62,7 +62,7 @@ namespace panda { class JSNApiHelper { public: - template + template static inline Local ToLocal(ecmascript::JSHandle from); static inline ecmascript::JSTaggedValue ToJSTaggedValue(JSValueRef *from); diff --git a/runtime/object_operator.cpp b/runtime/object_operator.cpp index 7b7e171bc..d8fc375be 100644 --- a/runtime/object_operator.cpp +++ b/runtime/object_operator.cpp @@ -480,7 +480,7 @@ bool ObjectOperator::WriteDataProperty(const JSHandle &receiver, const return UpdateValueAndDetails(receiver, desc.GetValue(), attr, attrChanged); } - + if (IsAccessorDescriptor() && !IsElement()) { TaggedArray *properties = TaggedArray::Cast(receiver->GetProperties().GetTaggedObject()); if (!properties->IsDictionaryMode()) { diff --git a/runtime/object_operator.h b/runtime/object_operator.h index 167ac85ca..10a850f3d 100644 --- a/runtime/object_operator.h +++ b/runtime/object_operator.h @@ -293,15 +293,15 @@ private: bool UpdateValueAndDetails(const JSHandle &receiver, const JSHandle &value, PropertyAttributes attr, bool attrChanged); void TransitionForAttributeChanged(const JSHandle &receiver, PropertyAttributes attr); - JSThread *thread_{nullptr}; - JSMutableHandle value_{}; - JSMutableHandle holder_{}; - JSMutableHandle receiver_{}; - JSHandle key_{}; - uint32_t elementIndex_{NOT_FOUND_INDEX}; - uint32_t index_{NOT_FOUND_INDEX}; + JSThread *thread_ {nullptr}; + JSMutableHandle value_ {}; + JSMutableHandle holder_ {}; + JSMutableHandle receiver_ {}; + JSHandle key_ {}; + uint32_t elementIndex_ {NOT_FOUND_INDEX}; + uint32_t index_ {NOT_FOUND_INDEX}; PropertyAttributes attributes_; - uint32_t metaData_{0}; + uint32_t metaData_ {0}; }; } // namespace panda::ecmascript #endif // ECMASCRIPT_OBJECT_OPERATOR_H diff --git a/runtime/property_attributes.h b/runtime/property_attributes.h index 7fb1f0fe2..e410a0bd4 100644 --- a/runtime/property_attributes.h +++ b/runtime/property_attributes.h @@ -60,7 +60,7 @@ public: static constexpr uint32_t OFFSET_BITFIELD_NUM = 10; static constexpr uint32_t MAX_CAPACITY_OF_PROPERTIES = (1U << OFFSET_BITFIELD_NUM) - 1; - using PropertyMetaDataField = BitField; // 4: property metaData field occupies 4 bits + using PropertyMetaDataField = BitField; // 4: property metaData field occupies 4 bits using AttributesField = BitField; // 4: attributes field occupies 4 bits using DefaultAttributesField = BitField; // 3: default attributes field occupies 3 bits using WritableField = BitField; // 1: writable field occupies 1 bits @@ -69,7 +69,7 @@ public: using IsAccessorField = ConfigurableField::NextFlag; // 4 // fast mode - using IsInlinedPropsField = PropertyMetaDataField::NextFlag; // 5 + using IsInlinedPropsField = PropertyMetaDataField::NextFlag; // 5 using RepresentationField = IsInlinedPropsField::NextField; // 3: 3 bits, 6-8 using OffsetField = RepresentationField::NextField; // 18 @@ -78,7 +78,7 @@ public: using SortedIndexField = OffsetField::NextField; // 28 using IsConstPropsField = SortedIndexField::NextFlag; // 29 // dictionary mode, include global - using PropertyBoxTypeField = PropertyMetaDataField::NextField; // 2: 2 bits, 5-6 + using PropertyBoxTypeField = PropertyMetaDataField::NextField; // 2: 2 bits, 5-6 using DictionaryOrderField = PropertyBoxTypeField::NextField; // 26 static constexpr uint32_t BIT_SIZE = 28; @@ -306,7 +306,7 @@ public: } private: - uint32_t value_{0}; + uint32_t value_ {0}; }; } // namespace panda::ecmascript #endif // ECMASCRIPT_PROPERTY_ATTRIBUTES_H diff --git a/runtime/regexp/regexp_executor.cpp b/runtime/regexp/regexp_executor.cpp index 7c06e5a2f..1001c72b6 100644 --- a/runtime/regexp/regexp_executor.cpp +++ b/runtime/regexp/regexp_executor.cpp @@ -170,9 +170,9 @@ bool RegExpExecutor::HandleOpWordBoundary(uint8_t opCode) } bool currentIsWord = IsWordChar(PeekChar(currentPtr_, inputEnd_)); if (((opCode == RegExpOpCode::OP_WORD_BOUNDARY) && - ((!preIsWord && currentIsWord) || (preIsWord && !currentIsWord))) || + ((!preIsWord && currentIsWord) || (preIsWord && !currentIsWord))) || ((opCode == RegExpOpCode::OP_NOT_WORD_BOUNDARY) && - ((preIsWord && currentIsWord) || (!preIsWord && !currentIsWord)))) { + ((preIsWord && currentIsWord) || (!preIsWord && !currentIsWord)))) { Advance(opCode); } else { if (MatchFailed()) { @@ -326,7 +326,7 @@ bool RegExpExecutor::HandleOpRange32(const DynChunk &byteCode) idx = (idxMin + idxMax) / RANGE32_OFFSET; low = byteCode.GetU32(GetCurrentPC() + RANGE32_HEAD_OFFSET + idx * RANGE32_MAX_OFFSET); high = byteCode.GetU32(GetCurrentPC() + RANGE32_HEAD_OFFSET + idx * RANGE32_MAX_OFFSET + - RANGE32_MAX_HALF_OFFSET); + RANGE32_MAX_HALF_OFFSET); if (currentChar < low) { idxMax = idx - 1; } else if (currentChar > high) { diff --git a/runtime/regexp/regexp_opcode.h b/runtime/regexp/regexp_opcode.h index b3f651010..198ed1ffe 100644 --- a/runtime/regexp/regexp_opcode.h +++ b/runtime/regexp/regexp_opcode.h @@ -89,8 +89,8 @@ public: virtual uint32_t DumpOpCode(std::ostream &out, const DynChunk &buf, uint32_t offset) const = 0; private: - uint8_t opCode_{0}; - uint8_t size_{0}; + uint8_t opCode_ {0}; + uint8_t size_ {0}; }; class SaveStartOpCode : public RegExpOpCode { @@ -366,7 +366,7 @@ public: private: friend class RangeOpCode; friend class Range32OpCode; - std::list> rangeSet_{}; + std::list> rangeSet_ {}; }; class RangeOpCode : public RegExpOpCode { diff --git a/runtime/regexp/regexp_parser_cache.cpp b/runtime/regexp/regexp_parser_cache.cpp index 65eb81731..3ee4d2e33 100644 --- a/runtime/regexp/regexp_parser_cache.cpp +++ b/runtime/regexp/regexp_parser_cache.cpp @@ -30,7 +30,7 @@ void RegExpParserCache::Clear() { for (ParserKey &info : info_) { info.pattern_ = nullptr; - info.flags_ = UINT32_MAX; // flags cannot be UINT32_MAX, so it means invalid. + info.flags_ = UINT32_MAX; // flags cannot be UINT32_MAX, so it means invalid. info.codeBuffer_ = JSTaggedValue::Hole(); info.bufferSize_ = 0; } @@ -51,8 +51,8 @@ std::pair RegExpParserCache::GetCache(EcmaString *pattern return std::pair(info.codeBuffer_, info.bufferSize_); } -void RegExpParserCache::SetCache(EcmaString *pattern, const uint32_t flags, - const JSTaggedValue codeBuffer, const size_t bufferSize) +void RegExpParserCache::SetCache(EcmaString *pattern, const uint32_t flags, const JSTaggedValue codeBuffer, + const size_t bufferSize) { size_t hash = GetHash(pattern, flags); ParserKey &info = info_[hash]; diff --git a/runtime/regexp/regexp_parser_cache.h b/runtime/regexp/regexp_parser_cache.h index 397d3e5a3..874f727ae 100644 --- a/runtime/regexp/regexp_parser_cache.h +++ b/runtime/regexp/regexp_parser_cache.h @@ -40,13 +40,13 @@ private: size_t GetHash(EcmaString *pattern, uint32_t flags); struct ParserKey { - EcmaString *pattern_{nullptr}; - uint32_t flags_{UINT32_MAX}; - JSTaggedValue codeBuffer_{JSTaggedValue::Hole()}; - size_t bufferSize_{0}; + EcmaString *pattern_ {nullptr}; + uint32_t flags_ {UINT32_MAX}; + JSTaggedValue codeBuffer_ {JSTaggedValue::Hole()}; + size_t bufferSize_ {0}; }; - std::array info_{}; + std::array info_ {}; }; } // namespace panda::ecmascript #endif // ECMASCRIPT_REGEXP_PARSER_CACHE_H diff --git a/runtime/runtime_call_id.h b/runtime/runtime_call_id.h index 766deb375..241354aa9 100644 --- a/runtime/runtime_call_id.h +++ b/runtime/runtime_call_id.h @@ -557,8 +557,7 @@ namespace panda::ecmascript { V(ArrayList, Iterator) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ABSTRACT_OPERATION_LIST(V) \ - V(JSTaggedValue, ToString) \ +#define ABSTRACT_OPERATION_LIST(V) V(JSTaggedValue, ToString) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define INTERPRETER_CALLER_ID(name) INTERPRETER_ID_##name, @@ -571,8 +570,7 @@ namespace panda::ecmascript { enum EcmaRuntimeCallerId { INTERPRETER_CALLER_LIST(INTERPRETER_CALLER_ID) BUITINS_API_LIST(BUILTINS_API_ID) - ABSTRACT_OPERATION_LIST(ABSTRACT_OPERATION_ID) - RUNTIME_CALLER_NUMBER, + ABSTRACT_OPERATION_LIST(ABSTRACT_OPERATION_ID) RUNTIME_CALLER_NUMBER, }; #if ECMASCRIPT_ENABLE_RUNTIME_STAT @@ -595,9 +593,9 @@ enum EcmaRuntimeCallerId { RuntimeTimerScope abstract_##class##name##_scope_(thread, ABSTRACT_OPERATION_ID(class, name) _run_stat_) #else -#define INTERPRETER_TRACE(thread, name) static_cast(0) // NOLINT(cppcoreguidelines-macro-usage) -#define BUILTINS_API_TRACE(thread, class, name) static_cast(0) // NOLINT(cppcoreguidelines-macro-usage) +#define INTERPRETER_TRACE(thread, name) static_cast(0) // NOLINT(cppcoreguidelines-macro-usage) +#define BUILTINS_API_TRACE(thread, class, name) static_cast(0) // NOLINT(cppcoreguidelines-macro-usage) #define ABSTRACT_OPERATION_TRACE(thread, class, name) static_cast(0) // NOLINT(cppcoreguidelines-macro-usage) -#endif // ECMASCRIPT_ENABLE_RUNTIME_STAT +#endif // ECMASCRIPT_ENABLE_RUNTIME_STAT } // namespace panda::ecmascript #endif diff --git a/runtime/snapshot/mem/snapshot.cpp b/runtime/snapshot/mem/snapshot.cpp index be2a667f0..90bfd2399 100644 --- a/runtime/snapshot/mem/snapshot.cpp +++ b/runtime/snapshot/mem/snapshot.cpp @@ -146,7 +146,7 @@ std::unique_ptr SnapShot::DeserializeGlobalEnvAndProgram uintptr_t snapshot_begin = readFile + sizeof(Header); for (size_t i = 0; i < hdr.snapshot_size / DEFAULT_SNAPSHOT_SPACE_SIZE; i++) { Region *region = const_cast(vm_->GetHeap()->GetRegionFactory()) - ->AllocateAlignedRegion(space, DEFAULT_SNAPSHOT_SPACE_SIZE); + ->AllocateAlignedRegion(space, DEFAULT_SNAPSHOT_SPACE_SIZE); auto fileRegion = ToNativePtr(snapshot_begin + i * DEFAULT_SNAPSHOT_SPACE_SIZE); uint64_t base = region->allocateBase_; diff --git a/runtime/snapshot/mem/snapshot.h b/runtime/snapshot/mem/snapshot.h index 9e97403f8..920a2aea9 100644 --- a/runtime/snapshot/mem/snapshot.h +++ b/runtime/snapshot/mem/snapshot.h @@ -33,8 +33,7 @@ public: void MakeSnapShotProgramObject(Program *program, const panda_file::File *pf, const CString &fileName = "./snapshot"); - std::unique_ptr DeserializeGlobalEnvAndProgram( - const CString &fileName = "./snapshot"); + std::unique_ptr DeserializeGlobalEnvAndProgram(const CString &fileName = "./snapshot"); private: struct Header { diff --git a/runtime/snapshot/mem/snapshot_serialize.h b/runtime/snapshot/mem/snapshot_serialize.h index 62d96df50..f14c12876 100644 --- a/runtime/snapshot/mem/snapshot_serialize.h +++ b/runtime/snapshot/mem/snapshot_serialize.h @@ -51,17 +51,14 @@ private: void NativePointerSerialize(TaggedObject *objectHeader, uintptr_t snapshotObj); void JSObjectSerialize(TaggedObject *objectHeader, uintptr_t snapshotObj, size_t objectSize, - CQueue *queue, - std::unordered_map *data); + CQueue *queue, std::unordered_map *data); void JSFunctionBaseSerialize(TaggedObject *objectHeader, uintptr_t snapshotObj, size_t objectSize, CQueue *queue, std::unordered_map *data); void JSProxySerialize(TaggedObject *objectHeader, uintptr_t snapshotObj, size_t objectSize, - CQueue *queue, - std::unordered_map *data); + CQueue *queue, std::unordered_map *data); void DynClassSerialize(TaggedObject *objectHeader, uintptr_t snapshotObj, size_t objectSize, - CQueue *queue, - std::unordered_map *data); + CQueue *queue, std::unordered_map *data); void DynArraySerialize(TaggedObject *objectHeader, uintptr_t snapshotObj, CQueue *queue, std::unordered_map *data); void DynStringSerialize(TaggedObject *objectHeader, uintptr_t snapshotObj); @@ -78,8 +75,7 @@ private: void DynProgramDeserialize(uint64_t *objectHeader, size_t objectSize); SlotBit HandleObjectHeader(TaggedObject *objectHeader, uint8_t objectType, size_t objectSize, - CQueue *queue, - std::unordered_map *data); + CQueue *queue, std::unordered_map *data); uint64_t HandleTaggedField(JSTaggedType *tagged, CQueue *queue, std::unordered_map *data); void DeserializeHandleTaggedField(uint64_t *value); @@ -93,7 +89,7 @@ private: *addr = value; } - template + template T GetAddress(size_t index) { return *reinterpret_cast(addressSlot_ + index * ADDRESS_SIZE); @@ -103,11 +99,11 @@ private: void *NativePointerSlotBitToAddr(SlotBit native); void DeserializeRangeTaggedField(size_t beginAddr, int numOfFields); - EcmaVM *vm_{nullptr}; - bool serialize_{false}; - bool programSerialize_{false}; - int count_{0}; - int objectArraySize_{0}; + EcmaVM *vm_ {nullptr}; + bool serialize_ {false}; + bool programSerialize_ {false}; + int count_ {0}; + int objectArraySize_ {0}; uintptr_t addressSlot_; CVector pandaMethod_; diff --git a/runtime/tagged_array-inl.h b/runtime/tagged_array-inl.h index 00217f8ee..44a123dfb 100644 --- a/runtime/tagged_array-inl.h +++ b/runtime/tagged_array-inl.h @@ -48,7 +48,7 @@ inline uint32_t TaggedArray::GetIdx(const JSTaggedValue &value) const return TaggedArray::MAX_ARRAY_INDEX; } -template +template inline void TaggedArray::Set(const JSThread *thread, uint32_t idx, const JSHandle &value) { ASSERT(idx < GetLength()); diff --git a/runtime/tagged_array.h b/runtime/tagged_array.h index c1f2761f3..fe6cb89e8 100644 --- a/runtime/tagged_array.h +++ b/runtime/tagged_array.h @@ -38,7 +38,7 @@ public: uint32_t GetIdx(const JSTaggedValue &value) const; - template + template void Set(const JSThread *thread, uint32_t idx, const JSHandle &value); JSTaggedValue Get(const JSThread *thread, uint32_t idx) const; @@ -72,8 +72,7 @@ public: bool HasDuplicateEntry() const; - static JSHandle SetCapacity(const JSThread *thread, const JSHandle &array, - uint32_t capa); + static JSHandle SetCapacity(const JSThread *thread, const JSHandle &array, uint32_t capa); inline void InitializeWithSpecialValue(JSTaggedValue initValue, uint32_t length); diff --git a/runtime/tagged_hash_table-inl.h b/runtime/tagged_hash_table-inl.h index 9eb05ca8a..3ffaa50c3 100644 --- a/runtime/tagged_hash_table-inl.h +++ b/runtime/tagged_hash_table-inl.h @@ -21,56 +21,56 @@ #include "plugins/ecmascript/runtime/tagged_hash_table.h" namespace panda::ecmascript { -template +template int TaggedHashTable::EntriesCount() const { return Get(NUMBER_OF_ENTRIES_INDEX).GetInt(); } -template +template int TaggedHashTable::HoleEntriesCount() const { return Get(NUMBER_OF_HOLE_ENTRIES_INDEX).GetInt(); } -template +template int TaggedHashTable::Size() const { return Get(SIZE_INDEX).GetInt(); } -template +template void TaggedHashTable::IncreaseEntries(const JSThread *thread) { SetEntriesCount(thread, EntriesCount() + 1); } -template +template void TaggedHashTable::IncreaseHoleEntriesCount(const JSThread *thread, int number) { SetEntriesCount(thread, EntriesCount() - number); SetHoleEntriesCount(thread, HoleEntriesCount() + number); } -template +template void TaggedHashTable::SetEntriesCount(const JSThread *thread, int nof) { Set(thread, NUMBER_OF_ENTRIES_INDEX, JSTaggedValue(nof)); } -template +template void TaggedHashTable::SetHoleEntriesCount(const JSThread *thread, int nod) { Set(thread, NUMBER_OF_HOLE_ENTRIES_INDEX, JSTaggedValue(nod)); } -template +template void TaggedHashTable::SetHashTableSize(const JSThread *thread, int size) { Set(thread, SIZE_INDEX, JSTaggedValue(size)); } -template +template void TaggedHashTable::GetAllKeys(const JSThread *thread, int offset, TaggedArray *keyArray) const { ASSERT_PRINT(offset + EntriesCount() <= static_cast(keyArray->GetLength()), @@ -87,7 +87,7 @@ void TaggedHashTable::GetAllKeys(const JSThread *thread, int offset, Ta } // Find entry for key otherwise return -1. -template +template int TaggedHashTable::FindEntry(const JSTaggedValue &key) { size_t size = Size(); @@ -111,7 +111,7 @@ int TaggedHashTable::FindEntry(const JSTaggedValue &key) } // static -template +template int TaggedHashTable::RecalculateTableSize(int currentSize, int atLeastSize) { // When the filled entries is greater than a quart of currentSize @@ -130,7 +130,7 @@ int TaggedHashTable::RecalculateTableSize(int currentSize, int atLeastS } // static -template +template JSHandle TaggedHashTable::Shrink(const JSThread *thread, const JSHandle &table, int additionalSize) { @@ -148,7 +148,7 @@ JSHandle TaggedHashTable::Shrink(const JSThread *thread, const return newTable; } -template +template bool TaggedHashTable::IsNeedGrowHashTable(int numOfAddEntries) { int entriesCount = EntriesCount(); @@ -168,7 +168,7 @@ bool TaggedHashTable::IsNeedGrowHashTable(int numOfAddEntries) return true; } -template +template void TaggedHashTable::AddElement(const JSThread *thread, int entry, const JSHandle &key, const JSHandle &value) { @@ -177,7 +177,7 @@ void TaggedHashTable::AddElement(const JSThread *thread, int entry, con this->IncreaseEntries(thread); } -template +template void TaggedHashTable::RemoveElement(const JSThread *thread, int entry) { JSTaggedValue defaultValue(JSTaggedValue::Hole()); @@ -186,7 +186,7 @@ void TaggedHashTable::RemoveElement(const JSThread *thread, int entry) this->IncreaseHoleEntriesCount(thread); } -template +template JSHandle TaggedHashTable::Insert(const JSThread *thread, JSHandle &table, const JSHandle &key, const JSHandle &value) @@ -204,7 +204,7 @@ JSHandle TaggedHashTable::Insert(const JSThread *thread, JSHan return newTable; } -template +template JSHandle TaggedHashTable::Remove(const JSThread *thread, JSHandle &table, const JSHandle &key) { @@ -217,7 +217,7 @@ JSHandle TaggedHashTable::Remove(const JSThread *thread, JSHan return Derived::Shrink(thread, *table); } -template +template void TaggedHashTable::Rehash(const JSThread *thread, Derived *newTable) { if ((newTable == nullptr) || (newTable->Size() < EntriesCount())) { @@ -245,7 +245,7 @@ void TaggedHashTable::Rehash(const JSThread *thread, Derived *newTable) } // static -template +template int TaggedHashTable::ComputeHashTableSize(uint32_t atLeastSize) { // increase size for hash-collision @@ -254,7 +254,7 @@ int TaggedHashTable::ComputeHashTableSize(uint32_t atLeastSize) return (newSize > MIN_SIZE) ? newSize : MIN_SIZE; } -template +template JSHandle TaggedHashTable::GrowHashTable(const JSThread *thread, const JSHandle &table, int numOfAddedElements) { @@ -269,7 +269,7 @@ JSHandle TaggedHashTable::GrowHashTable(const JSThread *thread return newTable; } -template +template JSHandle TaggedHashTable::Create(const JSThread *thread, int entriesCount) { ASSERT_PRINT((entriesCount > 0), "the size must be greater than zero"); @@ -285,7 +285,7 @@ JSHandle TaggedHashTable::Create(const JSThread *thread, int e return table; } -template +template void TaggedHashTable::SetKey(const JSThread *thread, int entry, const JSTaggedValue &key) { int index = Derived::GetKeyIndex(entry); @@ -295,7 +295,7 @@ void TaggedHashTable::SetKey(const JSThread *thread, int entry, const J Set(thread, index, key); } -template +template JSTaggedValue TaggedHashTable::GetKey(int entry) const { int index = Derived::GetKeyIndex(entry); @@ -305,7 +305,7 @@ JSTaggedValue TaggedHashTable::GetKey(int entry) const return Get(index); } -template +template void TaggedHashTable::SetValue(const JSThread *thread, int entry, const JSTaggedValue &value) { int index = Derived::GetValueIndex(entry); @@ -315,7 +315,7 @@ void TaggedHashTable::SetValue(const JSThread *thread, int entry, const Set(thread, index, value); } -template +template JSTaggedValue TaggedHashTable::GetValue(int entry) const { int index = Derived::GetValueIndex(entry); @@ -325,7 +325,7 @@ JSTaggedValue TaggedHashTable::GetValue(int entry) const return Get(index); } -template +template int TaggedHashTable::FindInsertIndex(int hash) { int size = Size(); @@ -338,7 +338,7 @@ int TaggedHashTable::FindInsertIndex(int hash) } } -template +template JSHandle OrderTaggedHashTable::Create(const JSThread *thread, int numberOfElements) { JSHandle dict = HashTableT::Create(thread, numberOfElements); @@ -346,7 +346,7 @@ JSHandle OrderTaggedHashTable::Create(const JSThread *thread, return dict; } -template +template JSHandle OrderTaggedHashTable::PutIfAbsent(const JSThread *thread, const JSHandle &table, const JSHandle &key, const JSHandle &value, @@ -374,7 +374,7 @@ JSHandle OrderTaggedHashTable::PutIfAbsent(const JSThread *thr return newTable; } -template +template JSHandle OrderTaggedHashTable::Put(const JSThread *thread, const JSHandle &table, const JSHandle &key, const JSHandle &value, @@ -401,7 +401,7 @@ JSHandle OrderTaggedHashTable::Put(const JSThread *thread, con return newTable; } -template +template void TaggedHashTable::GetAllKeysIntoVector([[maybe_unused]] const JSThread *thread, std::vector &vector) const { @@ -414,7 +414,7 @@ void TaggedHashTable::GetAllKeysIntoVector([[maybe_unused]] const JSThr } } -template +template JSHandle OrderTaggedHashTable::Remove(const JSThread *thread, const JSHandle &table, int entry) { @@ -426,7 +426,7 @@ JSHandle OrderTaggedHashTable::Remove(const JSThread *thread, return Shrink(thread, table); } -template +template int OrderTaggedHashTable::NextEnumerationIndex(const JSThread *thread) { int index = GetNextEnumerationIndex(); @@ -447,7 +447,7 @@ int OrderTaggedHashTable::NextEnumerationIndex(const JSThread *thread) return index; } -template +template std::vector OrderTaggedHashTable::GetEnumerationOrder() { std::vector result; diff --git a/runtime/tagged_hash_table.h b/runtime/tagged_hash_table.h index 64881618c..4de99f3b3 100644 --- a/runtime/tagged_hash_table.h +++ b/runtime/tagged_hash_table.h @@ -22,7 +22,7 @@ #include "tagged_array.h" namespace panda::ecmascript { -template +template class TaggedHashTable : public TaggedArray { public: inline int EntriesCount() const; @@ -117,7 +117,7 @@ protected: void Rehash(const JSThread *thread, Derived *newTable); }; -template +template class OrderTaggedHashTable : public TaggedHashTable { public: using HashTableT = TaggedHashTable; diff --git a/runtime/vmstat/caller_stat.h b/runtime/vmstat/caller_stat.h index 7ac969e09..0771a690f 100644 --- a/runtime/vmstat/caller_stat.h +++ b/runtime/vmstat/caller_stat.h @@ -66,10 +66,10 @@ public: } private: - CString name_{}; - uint64_t totalCount_{0}; - uint64_t totalTime_{0}; - uint64_t maxTime_{0}; + CString name_ {}; + uint64_t totalCount_ {0}; + uint64_t totalTime_ {0}; + uint64_t maxTime_ {0}; }; class PandaRuntimeTimer { @@ -109,10 +109,10 @@ private: PandaRuntimeTimer *Stop(); void Pause(uint64_t now); void Resume(uint64_t now); - PandaRuntimeCallerStat *callerStat_{nullptr}; - PandaRuntimeTimer *parent_{nullptr}; - uint64_t start_{0}; - uint64_t elapsed_{0}; + PandaRuntimeCallerStat *callerStat_ {nullptr}; + PandaRuntimeTimer *parent_ {nullptr}; + uint64_t start_ {0}; + uint64_t elapsed_ {0}; friend class EcmaRuntimeStat; }; diff --git a/runtime/vmstat/runtime_stat.cpp b/runtime/vmstat/runtime_stat.cpp index 9d0659878..093bc7120 100644 --- a/runtime/vmstat/runtime_stat.cpp +++ b/runtime/vmstat/runtime_stat.cpp @@ -76,8 +76,8 @@ CString EcmaRuntimeStat::GetAllStats() const static constexpr int numberRightAdjustment = 20; statistic << std::right << std::setw(nameRightAdjustment) << "InterPreter && GC && C++ Builtin Function" << std::setw(numberRightAdjustment) << "Time(ns)" << std::setw(numberRightAdjustment) << "Count" - << std::setw(numberRightAdjustment) << "MaxTime(ns)" - << std::setw(numberRightAdjustment) << "AverageTime(ns)" << std::endl; + << std::setw(numberRightAdjustment) << "MaxTime(ns)" << std::setw(numberRightAdjustment) + << "AverageTime(ns)" << std::endl; statistic << "===========================================================================================" << "=======================================" << std::endl; @@ -86,9 +86,8 @@ CString EcmaRuntimeStat::GetAllStats() const statistic << std::right << std::setw(nameRightAdjustment) << runCallerStat.Name() << std::setw(numberRightAdjustment) << runCallerStat.TotalTime() << std::setw(numberRightAdjustment) << runCallerStat.TotalCount() - << std::setw(numberRightAdjustment) << runCallerStat.MaxTime() - << std::setw(numberRightAdjustment) << runCallerStat.TotalTime() / runCallerStat.TotalCount() - << std::endl; + << std::setw(numberRightAdjustment) << runCallerStat.MaxTime() << std::setw(numberRightAdjustment) + << runCallerStat.TotalTime() / runCallerStat.TotalCount() << std::endl; } } return statistic.str(); diff --git a/runtime/vmstat/runtime_stat.h b/runtime/vmstat/runtime_stat.h index 56f80b0d6..5c66d071b 100644 --- a/runtime/vmstat/runtime_stat.h +++ b/runtime/vmstat/runtime_stat.h @@ -25,7 +25,7 @@ namespace panda::ecmascript { class EcmaRuntimeStat { public: // NOLINTNEXTLINE(modernize-avoid-c-arrays) - explicit EcmaRuntimeStat(const char * const runtimeCallerNames[], int count); + explicit EcmaRuntimeStat(const char *const runtimeCallerNames[], int count); EcmaRuntimeStat() = default; virtual ~EcmaRuntimeStat() = default; @@ -40,7 +40,7 @@ public: private: PandaRuntimeTimer *currentTimer_ = nullptr; - CVector callerStat_{}; + CVector callerStat_ {}; }; class RuntimeTimerScope { @@ -73,8 +73,8 @@ public: NO_MOVE_SEMANTIC(RuntimeTimerScope); private: - PandaRuntimeTimer timer_{}; - EcmaRuntimeStat *stats_{nullptr}; + PandaRuntimeTimer timer_ {}; + EcmaRuntimeStat *stats_ {nullptr}; }; } // namespace panda::ecmascript #endif diff --git a/tests/bytecode_optimizer/reg_encoder_test_ecmascript.cpp b/tests/bytecode_optimizer/reg_encoder_test_ecmascript.cpp index 8adbc6872..272dabd98 100644 --- a/tests/bytecode_optimizer/reg_encoder_test_ecmascript.cpp +++ b/tests/bytecode_optimizer/reg_encoder_test_ecmascript.cpp @@ -92,15 +92,12 @@ TEST_F(CommonTest, RegEncoderEcmaSuperCallIntrinsic) EXPECT_TRUE(GraphComparator().Compare(graph, expected)); - auto expected_data = std::vector{std::make_tuple(compiler::LocationType::REGISTER, - compiler::LocationType::REGISTER, - compiler::INVALID_REG_ID, 0U), - std::make_tuple(compiler::LocationType::REGISTER, - compiler::LocationType::REGISTER, - compiler::INVALID_REG_ID, 1U), - std::make_tuple(compiler::LocationType::REGISTER, - compiler::LocationType::REGISTER, - compiler::INVALID_REG_ID, 2U)}; + auto expected_data = std::vector {std::make_tuple(compiler::LocationType::REGISTER, + compiler::LocationType::REGISTER, compiler::INVALID_REG_ID, 0U), + std::make_tuple(compiler::LocationType::REGISTER, + compiler::LocationType::REGISTER, compiler::INVALID_REG_ID, 1U), + std::make_tuple(compiler::LocationType::REGISTER, + compiler::LocationType::REGISTER, compiler::INVALID_REG_ID, 2U)}; size_t spill_fills = 0; for (auto block : graph->GetVectorBlocks()) { diff --git a/tests/runtime/builtins/builtins_array_test.cpp b/tests/runtime/builtins/builtins_array_test.cpp index 47e1e536d..ba19fbf08 100644 --- a/tests/runtime/builtins/builtins_array_test.cpp +++ b/tests/runtime/builtins/builtins_array_test.cpp @@ -83,7 +83,7 @@ public: { uint32_t argc = argv->GetArgsNumber(); if (argc > 0) { - if (GetCallArg(argv, 0)->GetInt() > 10) { // 10 : test case + if (GetCallArg(argv, 0)->GetInt() > 10) { // 10 : test case return GetTaggedBoolean(true); } } @@ -93,7 +93,7 @@ public: static JSTaggedValue TestMapFunc(EcmaRuntimeCallInfo *argv) { int accumulator = GetCallArg(argv, 0)->GetInt(); - accumulator = accumulator * 2; // 2 : mapped to 2 times the original value + accumulator = accumulator * 2; // 2 : mapped to 2 times the original value return BuiltinsBase::GetTaggedInt(accumulator); } @@ -139,7 +139,7 @@ public: { uint32_t argc = argv->GetArgsNumber(); if (argc > 0) { - if (GetCallArg(argv, 0)->GetInt() > 10) { // 10 : test case + if (GetCallArg(argv, 0)->GetInt() > 10) { // 10 : test case return GetTaggedBoolean(true); } } @@ -386,8 +386,8 @@ TEST_F(BuiltinsArrayTest, Concat) PropertyDescriptor descRes(thread); JSHandle valueHandle(thread, value); JSHandle key7(thread, JSTaggedValue(5)); - EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), 6); + EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), + 6); JSObject::GetOwnProperty(thread, valueHandle, key7, descRes); ASSERT_EQ(descRes.GetValue().GetTaggedValue(), JSTaggedValue(6)); } @@ -519,8 +519,8 @@ TEST_F(BuiltinsArrayTest, Map) PropertyDescriptor descRes(thread); JSHandle valueHandle(thread, value); - EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), 3); + EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), + 3); JSObject::GetOwnProperty(thread, valueHandle, key0, descRes); ASSERT_EQ(descRes.GetValue()->GetInt(), 100); @@ -559,8 +559,8 @@ TEST_F(BuiltinsArrayTest, Reverse) PropertyDescriptor descRes(thread); JSHandle valueHandle(thread, value); - EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), 3); + EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), + 3); JSObject::GetOwnProperty(thread, valueHandle, key0, descRes); ASSERT_EQ(descRes.GetValue().GetTaggedValue(), JSTaggedValue(3)); JSObject::GetOwnProperty(thread, valueHandle, key1, descRes); @@ -613,8 +613,8 @@ TEST_F(BuiltinsArrayTest, Slice) PropertyDescriptor descRes(thread); JSHandle valueHandle(thread, value); - EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), 3); + EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), + 3); JSObject::GetOwnProperty(thread, valueHandle, key0, descRes); ASSERT_EQ(descRes.GetValue().GetTaggedValue(), JSTaggedValue(2)); JSObject::GetOwnProperty(thread, valueHandle, key1, descRes); @@ -662,8 +662,8 @@ TEST_F(BuiltinsArrayTest, Splice) PropertyDescriptor descRes(thread); JSHandle valueHandle(thread, value); - EXPECT_EQ( - JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), 2); + EXPECT_EQ(JSArray::GetProperty(thread, JSHandle(valueHandle), lengthKeyHandle).GetValue()->GetInt(), + 2); JSObject::GetOwnProperty(thread, valueHandle, key0, descRes); ASSERT_EQ(descRes.GetValue().GetTaggedValue(), JSTaggedValue(2)); } diff --git a/tests/runtime/builtins/builtins_arraybuffer_test.cpp b/tests/runtime/builtins/builtins_arraybuffer_test.cpp index 3e6aa4132..d293abea8 100644 --- a/tests/runtime/builtins/builtins_arraybuffer_test.cpp +++ b/tests/runtime/builtins/builtins_arraybuffer_test.cpp @@ -115,7 +115,7 @@ TEST_F(BuiltinsArrayBufferTest, slice1) JSTaggedValue result1 = BuiltinsArrayBuffer::Slice(ecmaRuntimeCallInfo.get()); TestHelper::TearDownFrame(thread, prev); JSHandle arrBuf1(thread, - JSArrayBuffer::Cast(reinterpret_cast(result1.GetRawData()))); + JSArrayBuffer::Cast(reinterpret_cast(result1.GetRawData()))); auto ecmaRuntimeCallInfo1 = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 4); ecmaRuntimeCallInfo1->SetFunction(JSTaggedValue::Undefined()); ecmaRuntimeCallInfo1->SetThis(arrBuf1.GetTaggedValue()); diff --git a/tests/runtime/builtins/builtins_date_test.cpp b/tests/runtime/builtins/builtins_date_test.cpp index 3e44cdca5..aef295948 100644 --- a/tests/runtime/builtins/builtins_date_test.cpp +++ b/tests/runtime/builtins/builtins_date_test.cpp @@ -745,7 +745,7 @@ static CString GetLocalTime(JSHandle jsDate, int64_t localMin) CString localTime = ""; localMin = JSDate::GetLocalOffsetFromOS(localMin, true); if (static_cast(JSDate::Cast(jsDate.GetTaggedValue().GetTaggedObject())->GetTimeValue().GetDouble()) < - CHINA_BEFORE_1900_MS && + CHINA_BEFORE_1900_MS && localMin == CHINA_AFTER_1901_MIN) { localMin = CHINA_BEFORE_1901_MIN; } diff --git a/tests/runtime/builtins/builtins_json_test.cpp b/tests/runtime/builtins/builtins_json_test.cpp index 11b595602..97502ca11 100644 --- a/tests/runtime/builtins/builtins_json_test.cpp +++ b/tests/runtime/builtins/builtins_json_test.cpp @@ -129,7 +129,7 @@ JSTaggedValue CreateBuiltinJSObject1(JSThread *thread, const CString keyCStr) CString str2 = "y"; JSHandle key2(factory->NewFromCanBeCompressString(str2)); - JSHandle value2(thread, JSTaggedValue(2.5)); // 2.5 : test case + JSHandle value2(thread, JSTaggedValue(2.5)); // 2.5 : test case JSObject::SetProperty(thread, JSHandle(jsobject), key2, value2); CString str3 = "z"; @@ -237,8 +237,7 @@ TEST_F(BuiltinsJsonTest, Stringify11) ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); - JSHandle handleFunc = - factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); + JSHandle handleFunc = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); @@ -256,8 +255,7 @@ TEST_F(BuiltinsJsonTest, Stringify12) ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle handleFunc = - factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); + JSHandle handleFunc = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 10); ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); @@ -276,8 +274,7 @@ TEST_F(BuiltinsJsonTest, Stringify13) ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle obj = JSHandle(thread, CreateBuiltinJSObject1(thread, "x")); JSHandle env = thread->GetEcmaVM()->GetGlobalEnv(); - JSHandle handleFunc = - factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); + JSHandle handleFunc = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); JSHandle msg(factory->NewFromCanBeCompressString("tttt")); JSHandle str(JSTaggedValue::ToString(thread, msg)); @@ -358,8 +355,7 @@ TEST_F(BuiltinsJsonTest, Stringify1) JSHandle value2(factory->NewFromCanBeCompressString("abc")); JSObject::SetProperty(thread, JSHandle(obj), key2, value2); - JSHandle handleFunc = - factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); + JSHandle handleFunc = factory->NewJSFunction(env, reinterpret_cast(TestClass::TestForStringfy)); JSHandle msg(factory->NewFromCanBeCompressString("tttt")); JSHandle str(JSTaggedValue::ToString(thread, msg)); diff --git a/tests/runtime/builtins/builtins_number_test.cpp b/tests/runtime/builtins/builtins_number_test.cpp index ababc24cc..ac964aca7 100644 --- a/tests/runtime/builtins/builtins_number_test.cpp +++ b/tests/runtime/builtins/builtins_number_test.cpp @@ -304,7 +304,8 @@ TEST_F(BuiltinsNumberTest, ToFixed1) } // new Number(1e21).toFixed(20) -TEST_F(BuiltinsNumberTest, ToFixed2) { +TEST_F(BuiltinsNumberTest, ToFixed2) +{ ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); auto ecmaVM = thread->GetEcmaVM(); JSHandle env = ecmaVM->GetGlobalEnv(); @@ -313,8 +314,7 @@ TEST_F(BuiltinsNumberTest, ToFixed2) { JSHandle value(thread, JSTaggedValue(1e21)); JSHandle number = factory->NewJSPrimitiveRef(numberObject, value); - auto ecmaRuntimeCallInfo = - TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); + auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6); ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); ecmaRuntimeCallInfo->SetThis(number.GetTaggedValue()); ecmaRuntimeCallInfo->SetCallArg(0, JSTaggedValue(20.0)); diff --git a/tests/runtime/builtins/builtins_object_test.cpp b/tests/runtime/builtins/builtins_object_test.cpp index 3a971905e..1dea4d5cc 100644 --- a/tests/runtime/builtins/builtins_object_test.cpp +++ b/tests/runtime/builtins/builtins_object_test.cpp @@ -959,7 +959,6 @@ TEST_F(BuiltinsObjectTest, Values) JSHandle index0(thread, JSTaggedValue(0)); JSHandle index1(thread, JSTaggedValue(1)); - ASSERT_EQ(JSObject::GetProperty(thread, JSHandle(handle), index0).GetValue()->GetInt(), 1); ASSERT_EQ(JSObject::GetProperty(thread, JSHandle(handle), index1).GetValue()->GetInt(), 22); } diff --git a/tests/runtime/builtins/builtins_typedarray_test.cpp b/tests/runtime/builtins/builtins_typedarray_test.cpp index ea776764a..2258f94c9 100644 --- a/tests/runtime/builtins/builtins_typedarray_test.cpp +++ b/tests/runtime/builtins/builtins_typedarray_test.cpp @@ -117,7 +117,7 @@ protected: static JSTaggedValue TestMapFunc(EcmaRuntimeCallInfo *argv) { int accumulator = GetCallArg(argv, 0)->GetInt(); - accumulator = accumulator * 2; // 2 : mapped to 2 times the original value + accumulator = accumulator * 2; // 2 : mapped to 2 times the original value return BuiltinsBase::GetTaggedInt(accumulator); } @@ -209,7 +209,6 @@ JSTypedArray *CreateTypedArrayFromList(JSThread *thread, const JSHandleGetEcmaVM(); @@ -241,7 +240,6 @@ TEST_F(BuiltinsTypedArrayTest, Includes1) array->Set(thread, 4, JSTaggedValue(3)); JSHandle obj(thread, CreateTypedArrayFromList(thread, array)); - // new Array(1,2,3,4,3).includes(1,0) auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 8); ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); diff --git a/tests/runtime/builtins/builtins_weak_set_test.cpp b/tests/runtime/builtins/builtins_weak_set_test.cpp index efa59e77b..c8ae14bab 100644 --- a/tests/runtime/builtins/builtins_weak_set_test.cpp +++ b/tests/runtime/builtins/builtins_weak_set_test.cpp @@ -115,8 +115,7 @@ TEST_F(BuiltinsWeakSetTest, CreateAndGetSize) [[maybe_unused]] auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo.get()); JSTaggedValue result1 = BuiltinsWeakSet::WeakSetConstructor(ecmaRuntimeCallInfo.get()); - JSHandle weakSetResult(thread, - JSWeakSet::Cast(reinterpret_cast(result1.GetRawData()))); + JSHandle weakSetResult(thread, JSWeakSet::Cast(reinterpret_cast(result1.GetRawData()))); EXPECT_EQ(weakSetResult->GetSize(), 5); } diff --git a/tests/runtime/common/ecma_module_test.cpp b/tests/runtime/common/ecma_module_test.cpp index 2cdd0d725..649169e6d 100644 --- a/tests/runtime/common/ecma_module_test.cpp +++ b/tests/runtime/common/ecma_module_test.cpp @@ -74,7 +74,7 @@ TEST_F(EcmaModuleTest, AddItem_001) thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(cStrItemName)); JSHandle handleTagValItemValue(thread, JSTaggedValue(intItemValue)); - handleEcmaModule->SetNameDictionary(thread, handleNameDict); // Call SetNameDictionary in TEST_F + handleEcmaModule->SetNameDictionary(thread, handleNameDict); // Call SetNameDictionary in TEST_F EcmaModule::AddItem(thread, handleEcmaModule, handleTagValItemName, handleTagValItemValue); EXPECT_EQ(handleEcmaModule->GetItem(thread, handleTagValItemName)->GetNumber(), intItemValue); } @@ -112,7 +112,7 @@ TEST_F(EcmaModuleTest, AddItem_002) */ TEST_F(EcmaModuleTest, RemoveItem) { - ObjectFactory* objFactory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *objFactory = thread->GetEcmaVM()->GetFactory(); CString cStrItemName = "cStrItemName"; int intItemValue = 1; @@ -138,7 +138,7 @@ TEST_F(EcmaModuleTest, RemoveItem) */ TEST_F(EcmaModuleTest, SetNameDictionary) { - ObjectFactory* objFactory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *objFactory = thread->GetEcmaVM()->GetFactory(); int numOfElementsDict = 4; JSHandle handleNameDict(NameDictionary::Create(thread, numOfElementsDict)); @@ -146,15 +146,15 @@ TEST_F(EcmaModuleTest, SetNameDictionary) CString keyArray1 = "hello1"; JSHandle stringKey1 = objFactory->NewFromCanBeCompressString(keyArray1); JSHandle key1(stringKey1); - JSHandle value1(objFactory - ->NewJSObjectByConstructor(JSHandle(handleObjFunc), handleObjFunc)); + JSHandle value1( + objFactory->NewJSObjectByConstructor(JSHandle(handleObjFunc), handleObjFunc)); JSHandle handleNameDictionaryFrom( NameDictionary::Put(thread, handleNameDict, key1, value1, PropertyAttributes::Default())); JSHandle handleEcmaModule(thread, EcmaModuleCreate(thread)); handleEcmaModule->SetNameDictionary(thread, handleNameDictionaryFrom); - JSHandle handleNameDictionaryTo(thread, - NameDictionary::Cast(handleEcmaModule->GetNameDictionary().GetTaggedObject())); + JSHandle handleNameDictionaryTo( + thread, NameDictionary::Cast(handleEcmaModule->GetNameDictionary().GetTaggedObject())); EXPECT_EQ(handleNameDictionaryTo->EntriesCount(), 1); int entry1 = handleNameDictionaryTo->FindEntry(key1.GetTaggedValue()); EXPECT_TRUE(key1.GetTaggedValue() == handleNameDictionaryTo->GetKey(entry1)); @@ -172,7 +172,7 @@ TEST_F(EcmaModuleTest, SetNameDictionary) */ TEST_F(EcmaModuleTest, ModuleManager_AddModule) { - ObjectFactory* objFactory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *objFactory = thread->GetEcmaVM()->GetFactory(); ModuleManager *moduleManager = thread->GetEcmaVM()->GetModuleManager(); int numOfElementsDict1 = 4; @@ -205,14 +205,14 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModule) moduleManager->AddModule(handleTagValNameEcmaModuleAdd1, handleTagValEcmaModuleAddFrom1); moduleManager->AddModule(handleTagValNameEcmaModuleAdd2, handleTagValEcmaModuleAddFrom2); - JSHandle handleTagValEcmaModuleGet1 = moduleManager->GetModule(thread, - handleTagValNameEcmaModuleAdd1); - JSHandle handleTagValEcmaModuleGet2 = moduleManager->GetModule(thread, - handleTagValNameEcmaModuleAdd2); + JSHandle handleTagValEcmaModuleGet1 = + moduleManager->GetModule(thread, handleTagValNameEcmaModuleAdd1); + JSHandle handleTagValEcmaModuleGet2 = + moduleManager->GetModule(thread, handleTagValNameEcmaModuleAdd2); EXPECT_EQ(JSHandle::Cast(handleTagValEcmaModuleGet1)->GetItem(thread, handleItemName1)->GetNumber(), - intItemValue1); + intItemValue1); EXPECT_EQ(JSHandle::Cast(handleTagValEcmaModuleGet2)->GetItem(thread, handleItemName2)->GetNumber(), - intItemValue2); + intItemValue2); } /* @@ -227,7 +227,7 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModule) */ TEST_F(EcmaModuleTest, ModuleManager_RemoveModule) { - ObjectFactory* objFactory = thread->GetEcmaVM()->GetFactory(); + ObjectFactory *objFactory = thread->GetEcmaVM()->GetFactory(); ModuleManager *moduleManager = thread->GetEcmaVM()->GetModuleManager(); std::string stdStrNameEcmaModuleAdd1 = "NameEcmaModule1"; @@ -256,14 +256,20 @@ TEST_F(EcmaModuleTest, ModuleManager_RemoveModule) moduleManager->AddModule(handleTagValNameEcmaModuleAdd1, handleTaggedValueEcmaModuleAddFrom1); moduleManager->AddModule(handleTagValNameEcmaModuleAdd2, handleTaggedValueEcmaModuleAddFrom2); EXPECT_EQ(JSHandle::Cast(moduleManager->GetModule(thread, handleTagValNameEcmaModuleAdd1)) - ->GetItem(thread, handleTagValItemName1)->GetNumber(), intItemValue1); + ->GetItem(thread, handleTagValItemName1) + ->GetNumber(), + intItemValue1); EXPECT_EQ(JSHandle::Cast(moduleManager->GetModule(thread, handleTagValNameEcmaModuleAdd2)) - ->GetItem(thread, handleTagValItemName2)->GetNumber(), intItemValue2); + ->GetItem(thread, handleTagValItemName2) + ->GetNumber(), + intItemValue2); moduleManager->RemoveModule(handleTagValNameEcmaModuleAdd1); EXPECT_TRUE(moduleManager->GetModule(thread, handleTagValNameEcmaModuleAdd1)->IsUndefined()); EXPECT_EQ(JSHandle::Cast(moduleManager->GetModule(thread, handleTagValNameEcmaModuleAdd2)) - ->GetItem(thread, handleTagValItemName2)->GetNumber(), intItemValue2); + ->GetItem(thread, handleTagValItemName2) + ->GetNumber(), + intItemValue2); moduleManager->RemoveModule(handleTagValNameEcmaModuleAdd2); EXPECT_TRUE(moduleManager->GetModule(thread, handleTagValNameEcmaModuleAdd1)->IsUndefined()); @@ -384,9 +390,9 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModuleItem) moduleManager->AddModuleItem(thread, handleTagValItemName12, handleTagValItemValue12); EXPECT_EQ(moduleManager->GetModuleItem(thread, handleTagValEcmaModule1, handleTagValItemName11)->GetNumber(), - intItemValue11); + intItemValue11); EXPECT_EQ(moduleManager->GetModuleItem(thread, handleTagValEcmaModule1, handleTagValItemName12)->GetNumber(), - intItemValue12); + intItemValue12); // Test when the module is created through 'NewEmptyEcmaModule' function called at "ecma_module.cpp". moduleManager->SetCurrentExportModuleName(stdStrModuleFileName2); @@ -395,13 +401,13 @@ TEST_F(EcmaModuleTest, ModuleManager_AddModuleItem) JSHandle handleTagValEcmaModule2 = moduleManager->GetModule(thread, handleTagValEcmaModuleName2); EXPECT_EQ(moduleManager->GetModuleItem(thread, handleTagValEcmaModule1, handleTagValItemName11)->GetNumber(), - intItemValue11); + intItemValue11); EXPECT_EQ(moduleManager->GetModuleItem(thread, handleTagValEcmaModule1, handleTagValItemName12)->GetNumber(), - intItemValue12); + intItemValue12); EXPECT_EQ(moduleManager->GetModuleItem(thread, handleTagValEcmaModule2, handleTagValItemName21)->GetNumber(), - intItemValue21); + intItemValue21); EXPECT_EQ(moduleManager->GetModuleItem(thread, handleTagValEcmaModule2, handleTagValItemName22)->GetNumber(), - intItemValue22); + intItemValue22); } /* @@ -444,24 +450,24 @@ TEST_F(EcmaModuleTest, ModuleManager_CopyModule) moduleManager->SetCurrentExportModuleName(fileNameEcmaModuleCopyTo1); moduleManager->CopyModule(thread, handleTagValEcmaModuleCopyFrom1); - JSHandle handleTagValEcmaModuleCopyTo1 = moduleManager->GetModule(thread, - JSHandle::Cast(objFactory->NewFromString(CString(fileNameEcmaModuleCopyTo1)))); + JSHandle handleTagValEcmaModuleCopyTo1 = moduleManager->GetModule( + thread, JSHandle::Cast(objFactory->NewFromString(CString(fileNameEcmaModuleCopyTo1)))); EXPECT_EQ(intItemValue11, - moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName11)->GetNumber()); + moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName11)->GetNumber()); EXPECT_EQ(intItemValue12, - moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName12)->GetNumber()); + moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName12)->GetNumber()); moduleManager->SetCurrentExportModuleName(fileNameEcmaModuleCopyTo2); moduleManager->CopyModule(thread, handleTagValEcmaModuleCopyFrom2); - JSHandle handleTagValEcmaModuleCopyTo2 = moduleManager->GetModule(thread, - JSHandle::Cast(objFactory->NewFromString(CString(fileNameEcmaModuleCopyTo2)))); + JSHandle handleTagValEcmaModuleCopyTo2 = moduleManager->GetModule( + thread, JSHandle::Cast(objFactory->NewFromString(CString(fileNameEcmaModuleCopyTo2)))); EXPECT_EQ(intItemValue11, - moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName11)->GetNumber()); + moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName11)->GetNumber()); EXPECT_EQ(intItemValue12, - moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName12)->GetNumber()); + moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo1, handleTagValItemName12)->GetNumber()); EXPECT_EQ(intItemValue21, - moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo2, handleTagValItemName21)->GetNumber()); + moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo2, handleTagValItemName21)->GetNumber()); EXPECT_EQ(intItemValue22, - moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo2, handleTagValItemName22)->GetNumber()); + moduleManager->GetModuleItem(thread, handleTagValEcmaModuleCopyTo2, handleTagValItemName22)->GetNumber()); } -} // namespace panda::ecmascript +} // namespace panda::test diff --git a/tests/runtime/common/ecma_string_test.cpp b/tests/runtime/common/ecma_string_test.cpp index 09ce4358b..2013fa615 100644 --- a/tests/runtime/common/ecma_string_test.cpp +++ b/tests/runtime/common/ecma_string_test.cpp @@ -77,12 +77,12 @@ TEST_F(EcmaStringTest, CanBeCompressed) EXPECT_TRUE(EcmaString::CanBeCompressed(arrayU16Comp, sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]))); EXPECT_FALSE(EcmaString::CanBeCompressed(arrayU16NotComp, sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]))); - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. EXPECT_FALSE(EcmaString::CanBeCompressed(arrayU16NotComp, sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]))); /* Set compressedStringsEnabled default, because it is a static boolean that some other functions rely on.The foll- * owing TEST_F will come to an unexpected result if we do not set it default in the end of this TEST_F. */ - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -101,11 +101,11 @@ TEST_F(EcmaStringTest, CreateEmptyString) EXPECT_TRUE(handleEcmaStrEmpty->IsUtf8()); EXPECT_FALSE(handleEcmaStrEmpty->IsUtf16()); - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. JSHandle handleEcmaStrEmptyDisableComp(thread, EcmaString::CreateEmptyString(ecmaVMPtr)); EXPECT_EQ(handleEcmaStrEmptyDisableComp->GetLength(), 0); EXPECT_TRUE(handleEcmaStrEmptyDisableComp->IsUtf16()); - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -117,7 +117,7 @@ TEST_F(EcmaStringTest, CreateEmptyString) */ TEST_F(EcmaStringTest, AllocStringObject) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // AllocStringObject( , true, ). size_t sizeAllocComp = 5; @@ -132,18 +132,18 @@ TEST_F(EcmaStringTest, AllocStringObject) // AllocStringObject( , false, ). size_t sizeAllocNotComp = 5; JSHandle handleEcmaStrAllocNotComp(thread, - EcmaString::AllocStringObject(sizeAllocNotComp, false, ecmaVMPtr)); + EcmaString::AllocStringObject(sizeAllocNotComp, false, ecmaVMPtr)); for (size_t i = 0; i < sizeAllocNotComp; i++) { EXPECT_EQ(handleEcmaStrAllocNotComp->At(i), 0); } EXPECT_EQ(handleEcmaStrAllocNotComp->GetLength(), sizeAllocNotComp); EXPECT_FALSE(handleEcmaStrAllocNotComp->IsUtf8()); EXPECT_TRUE(handleEcmaStrAllocNotComp->IsUtf16()); - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. - JSHandle handleEcmaStrAllocNotCompDisableComp(thread, - EcmaString::AllocStringObject(sizeAllocNotComp, false, ecmaVMPtr)); + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + JSHandle handleEcmaStrAllocNotCompDisableComp( + thread, EcmaString::AllocStringObject(sizeAllocNotComp, false, ecmaVMPtr)); EXPECT_TRUE(handleEcmaStrAllocNotCompDisableComp->IsUtf16()); - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -154,11 +154,11 @@ TEST_F(EcmaStringTest, AllocStringObject) */ TEST_F(EcmaStringTest, CreateFromUtf8) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); uint8_t arrayU8[] = {"xyz123!@#"}; size_t lengthEcmaStrU8 = sizeof(arrayU8) - 1; JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); for (size_t i = 0; i < lengthEcmaStrU8; i++) { EXPECT_EQ(arrayU8[i], handleEcmaStrU8->At(i)); } @@ -176,13 +176,13 @@ TEST_F(EcmaStringTest, CreateFromUtf8) */ TEST_F(EcmaStringTest, CreateFromUtf16) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // CreateFromUtf16( , , , true). uint16_t arrayU16Comp[] = {1, 23, 45, 67, 127}; size_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); EXPECT_EQ(handleEcmaStrU16Comp->GetLength(), lengthEcmaStrU16Comp); EXPECT_TRUE(handleEcmaStrU16Comp->IsUtf8()); EXPECT_FALSE(handleEcmaStrU16Comp->IsUtf16()); @@ -190,16 +190,16 @@ TEST_F(EcmaStringTest, CreateFromUtf16) // CreateFromUtf16( , , , false). uint16_t arrayU16NotComp[] = {127, 33, 128, 12, 256, 11100, 65535}; size_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU16NotComp->GetLength(), lengthEcmaStrU16NotComp); EXPECT_FALSE(handleEcmaStrU16NotComp->IsUtf8()); EXPECT_TRUE(handleEcmaStrU16NotComp->IsUtf16()); - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. - JSHandle handleEcmaStrU16NotCompDisableComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + JSHandle handleEcmaStrU16NotCompDisableComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_TRUE(handleEcmaStrU16NotCompDisableComp->IsUtf16()); - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -255,40 +255,39 @@ TEST_F(EcmaStringTest, ComputeSizeUtf16) */ TEST_F(EcmaStringTest, ObjectSize) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); JSHandle handleEcmaStrEmpty(thread, EcmaString::CreateEmptyString(ecmaVMPtr)); EXPECT_EQ(handleEcmaStrEmpty->ObjectSize(), EcmaString::SIZE + 0); size_t lengthEcmaStrAllocComp = 5; JSHandle handleEcmaStrAllocComp(thread, - EcmaString::AllocStringObject(lengthEcmaStrAllocComp, true, ecmaVMPtr)); + EcmaString::AllocStringObject(lengthEcmaStrAllocComp, true, ecmaVMPtr)); EXPECT_EQ(handleEcmaStrAllocComp->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * lengthEcmaStrAllocComp); size_t lengthEcmaStrAllocNotComp = 5; - JSHandle handleEcmaStrAllocNotComp(thread, - EcmaString::AllocStringObject(lengthEcmaStrAllocNotComp, false, ecmaVMPtr)); - EXPECT_EQ(handleEcmaStrAllocNotComp->ObjectSize(), - EcmaString::SIZE + sizeof(uint16_t) * lengthEcmaStrAllocNotComp); + JSHandle handleEcmaStrAllocNotComp( + thread, EcmaString::AllocStringObject(lengthEcmaStrAllocNotComp, false, ecmaVMPtr)); + EXPECT_EQ(handleEcmaStrAllocNotComp->ObjectSize(), EcmaString::SIZE + sizeof(uint16_t) * lengthEcmaStrAllocNotComp); uint8_t arrayU8[] = {"abcde"}; size_t lengthEcmaStrU8 = sizeof(arrayU8) - 1; JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); EXPECT_EQ(handleEcmaStrU8->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * lengthEcmaStrU8); // ObjectSize(). EcmaString made by CreateFromUtf16( , , , true). uint16_t arrayU16Comp[] = {1, 23, 45, 67, 127}; size_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); EXPECT_EQ(handleEcmaStrU16Comp->ObjectSize(), EcmaString::SIZE + sizeof(uint8_t) * lengthEcmaStrU16Comp); // ObjectSize(). EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayU16NotComp[] = {127, 128, 256, 11100, 65535}; size_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU16NotComp->ObjectSize(), EcmaString::SIZE + sizeof(uint16_t) * lengthEcmaStrU16NotComp); } @@ -301,7 +300,7 @@ TEST_F(EcmaStringTest, ObjectSize) */ TEST_F(EcmaStringTest, Compare_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Compare(). Between EcmaStrings made by CreateFromUtf8(). uint8_t arrayU8No1[3] = {1, 23}; @@ -310,12 +309,12 @@ TEST_F(EcmaStringTest, Compare_001) uint32_t lengthEcmaStrU8No1 = sizeof(arrayU8No1) - 1; uint32_t lengthEcmaStrU8No2 = sizeof(arrayU8No2) - 1; uint32_t lengthEcmaStrU8No3 = sizeof(arrayU8No3) - 1; - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No2(thread, - EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No3(thread, - EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No2( + thread, EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No3( + thread, EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); EXPECT_EQ(handleEcmaStrU8No1->Compare(*handleEcmaStrU8No2), -1); EXPECT_EQ(handleEcmaStrU8No2->Compare(*handleEcmaStrU8No1), 1); EXPECT_EQ(handleEcmaStrU8No2->Compare(*handleEcmaStrU8No3), 49 - 45); @@ -331,7 +330,7 @@ TEST_F(EcmaStringTest, Compare_001) */ TEST_F(EcmaStringTest, Compare_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Compare(). Between EcmaStrings made by CreateFromUtf16( , , , true). uint16_t arrayU16CompNo1[] = {1, 23}; @@ -340,12 +339,12 @@ TEST_F(EcmaStringTest, Compare_002) uint32_t lengthEcmaStrU16CompNo1 = sizeof(arrayU16CompNo1) / sizeof(arrayU16CompNo1[0]); uint32_t lengthEcmaStrU16CompNo2 = sizeof(arrayU16CompNo2) / sizeof(arrayU16CompNo2[0]); uint32_t lengthEcmaStrU16CompNo3 = sizeof(arrayU16CompNo3) / sizeof(arrayU16CompNo3[0]); - JSHandle handleEcmaStrU16CompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); EXPECT_EQ(handleEcmaStrU16CompNo1->Compare(*handleEcmaStrU16CompNo2), -1); EXPECT_EQ(handleEcmaStrU16CompNo2->Compare(*handleEcmaStrU16CompNo1), 1); EXPECT_EQ(handleEcmaStrU16CompNo2->Compare(*handleEcmaStrU16CompNo3), 49 - 45); @@ -362,7 +361,7 @@ TEST_F(EcmaStringTest, Compare_002) */ TEST_F(EcmaStringTest, Compare_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Compare(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf16( , , , true). uint8_t arrayU8No1[3] = {1, 23}; @@ -375,16 +374,16 @@ TEST_F(EcmaStringTest, Compare_003) uint32_t lengthEcmaStrU16CompNo1 = sizeof(arrayU16CompNo1) / sizeof(arrayU16CompNo1[0]); uint32_t lengthEcmaStrU16CompNo2 = sizeof(arrayU16CompNo2) / sizeof(arrayU16CompNo2[0]); uint32_t lengthEcmaStrU16CompNo3 = sizeof(arrayU16CompNo3) / sizeof(arrayU16CompNo3[0]); - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No2(thread, - EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No2( + thread, EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); EXPECT_EQ(handleEcmaStrU8No1->Compare(*handleEcmaStrU16CompNo1), 0); EXPECT_EQ(handleEcmaStrU16CompNo1->Compare(*handleEcmaStrU8No1), 0); EXPECT_EQ(handleEcmaStrU8No1->Compare(*handleEcmaStrU16CompNo2), -1); @@ -402,7 +401,7 @@ TEST_F(EcmaStringTest, Compare_003) */ TEST_F(EcmaStringTest, Compare_004) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Compare(). Between EcmaStrings made by CreateFromUtf16( , , , false). uint16_t arrayU16NotCompNo1[] = {1, 23}; @@ -411,12 +410,12 @@ TEST_F(EcmaStringTest, Compare_004) uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); uint32_t lengthEcmaStrU16NotCompNo2 = sizeof(arrayU16NotCompNo2) / sizeof(arrayU16NotCompNo2[0]); uint32_t lengthEcmaStrU16NotCompNo3 = sizeof(arrayU16NotCompNo3) / sizeof(arrayU16NotCompNo3[0]); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU16NotCompNo1->Compare(*handleEcmaStrU16NotCompNo2), -1); EXPECT_EQ(handleEcmaStrU16NotCompNo2->Compare(*handleEcmaStrU16NotCompNo1), 1); EXPECT_EQ(handleEcmaStrU16NotCompNo2->Compare(*handleEcmaStrU16NotCompNo3), 49 - 456); @@ -432,7 +431,7 @@ TEST_F(EcmaStringTest, Compare_004) */ TEST_F(EcmaStringTest, Compare_005) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Compare(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf16( , , , false). uint8_t arrayU8No1[3] = {1, 23}; @@ -445,16 +444,16 @@ TEST_F(EcmaStringTest, Compare_005) uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); uint32_t lengthEcmaStrU16NotCompNo2 = sizeof(arrayU16NotCompNo2) / sizeof(arrayU16NotCompNo2[0]); uint32_t lengthEcmaStrU16NotCompNo3 = sizeof(arrayU16NotCompNo3) / sizeof(arrayU16NotCompNo3[0]); - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No2(thread, - EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No2( + thread, EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU8No1->Compare(*handleEcmaStrU16NotCompNo1), 0); EXPECT_EQ(handleEcmaStrU16NotCompNo1->Compare(*handleEcmaStrU8No1), 0); EXPECT_EQ(handleEcmaStrU8No1->Compare(*handleEcmaStrU16NotCompNo2), -1); @@ -472,7 +471,7 @@ TEST_F(EcmaStringTest, Compare_005) */ TEST_F(EcmaStringTest, Compare_006) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Compare(). EcmaString made by CreateFromUtf16( , , , true) and EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayU16CompNo1[] = {1, 23}; @@ -485,16 +484,16 @@ TEST_F(EcmaStringTest, Compare_006) uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); uint32_t lengthEcmaStrU16NotCompNo2 = sizeof(arrayU16NotCompNo2) / sizeof(arrayU16NotCompNo2[0]); uint32_t lengthEcmaStrU16NotCompNo3 = sizeof(arrayU16NotCompNo3) / sizeof(arrayU16NotCompNo3[0]); - JSHandle handleEcmaStrU16CompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16CompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU16CompNo1->Compare(*handleEcmaStrU16NotCompNo1), 0); EXPECT_EQ(handleEcmaStrU16NotCompNo1->Compare(*handleEcmaStrU16CompNo1), 0); EXPECT_EQ(handleEcmaStrU16CompNo1->Compare(*handleEcmaStrU16NotCompNo2), -1); @@ -512,19 +511,19 @@ TEST_F(EcmaStringTest, Compare_006) */ TEST_F(EcmaStringTest, Concat_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Concat(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf8(). uint8_t arrayFrontU8[] = {"abcdef"}; uint8_t arrayBackU8[] = {"ABCDEF"}; uint32_t lengthEcmaStrFrontU8 = sizeof(arrayFrontU8) - 1; uint32_t lengthEcmaStrBackU8 = sizeof(arrayBackU8) - 1; - JSHandle handleEcmaStrFrontU8(thread, - EcmaString::CreateFromUtf8(&arrayFrontU8[0], lengthEcmaStrFrontU8, ecmaVMPtr, true)); - JSHandle handleEcmaStrBackU8(thread, - EcmaString::CreateFromUtf8(&arrayBackU8[0], lengthEcmaStrBackU8, ecmaVMPtr, true)); - JSHandle handleEcmaStrConcatU8(thread, - EcmaString::Concat(handleEcmaStrFrontU8, handleEcmaStrBackU8, ecmaVMPtr)); + JSHandle handleEcmaStrFrontU8( + thread, EcmaString::CreateFromUtf8(&arrayFrontU8[0], lengthEcmaStrFrontU8, ecmaVMPtr, true)); + JSHandle handleEcmaStrBackU8( + thread, EcmaString::CreateFromUtf8(&arrayBackU8[0], lengthEcmaStrBackU8, ecmaVMPtr, true)); + JSHandle handleEcmaStrConcatU8( + thread, EcmaString::Concat(handleEcmaStrFrontU8, handleEcmaStrBackU8, ecmaVMPtr)); EXPECT_TRUE(handleEcmaStrConcatU8->IsUtf8()); for (size_t i = 0; i < lengthEcmaStrFrontU8; i++) { EXPECT_EQ(handleEcmaStrConcatU8->At(i), arrayFrontU8[i]); @@ -544,19 +543,19 @@ TEST_F(EcmaStringTest, Concat_001) */ TEST_F(EcmaStringTest, Concat_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Concat(). EcmaString made by CreateFromUtf16( , , , false) and EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayFrontU16NotComp[] = {128, 129, 256, 11100, 65535, 100}; uint16_t arrayBackU16NotComp[] = {88, 768, 1, 270, 345, 333}; uint32_t lengthEcmaStrFrontU16NotComp = sizeof(arrayFrontU16NotComp) / sizeof(arrayFrontU16NotComp[0]); uint32_t lengthEcmaStrBackU16NotComp = sizeof(arrayBackU16NotComp) / sizeof(arrayBackU16NotComp[0]); - JSHandle handleEcmaStrFrontU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayFrontU16NotComp[0], lengthEcmaStrFrontU16NotComp, ecmaVMPtr, false)); - JSHandle handleEcmaStrBackU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayBackU16NotComp[0], lengthEcmaStrBackU16NotComp, ecmaVMPtr, false)); - JSHandle handleEcmaStrConcatU16NotComp(thread, - EcmaString::Concat(handleEcmaStrFrontU16NotComp, handleEcmaStrBackU16NotComp, ecmaVMPtr)); + JSHandle handleEcmaStrFrontU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayFrontU16NotComp[0], lengthEcmaStrFrontU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrBackU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayBackU16NotComp[0], lengthEcmaStrBackU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrConcatU16NotComp( + thread, EcmaString::Concat(handleEcmaStrFrontU16NotComp, handleEcmaStrBackU16NotComp, ecmaVMPtr)); EXPECT_TRUE(handleEcmaStrConcatU16NotComp->IsUtf16()); for (size_t i = 0; i < lengthEcmaStrFrontU16NotComp; i++) { EXPECT_EQ(handleEcmaStrConcatU16NotComp->At(i), arrayFrontU16NotComp[i]); @@ -576,19 +575,19 @@ TEST_F(EcmaStringTest, Concat_002) */ TEST_F(EcmaStringTest, Concat_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // Concat(). EcmaString made by CreateFromUtf8() and EcmaString made by CreateFromUtf16( , , , false). uint8_t arrayFrontU8[] = {"abcdef"}; uint16_t arrayBackU16NotComp[] = {88, 768, 1, 270, 345, 333}; uint32_t lengthEcmaStrFrontU8 = sizeof(arrayFrontU8) - 1; uint32_t lengthEcmaStrBackU16NotComp = sizeof(arrayBackU16NotComp) / sizeof(arrayBackU16NotComp[0]); - JSHandle handleEcmaStrFrontU8(thread, - EcmaString::CreateFromUtf8(&arrayFrontU8[0], lengthEcmaStrFrontU8, ecmaVMPtr, true)); - JSHandle handleEcmaStrBackU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayBackU16NotComp[0], lengthEcmaStrBackU16NotComp, ecmaVMPtr, false)); - JSHandle handleEcmaStrConcatU8U16NotComp(thread, - EcmaString::Concat(handleEcmaStrFrontU8, handleEcmaStrBackU16NotComp, ecmaVMPtr)); + JSHandle handleEcmaStrFrontU8( + thread, EcmaString::CreateFromUtf8(&arrayFrontU8[0], lengthEcmaStrFrontU8, ecmaVMPtr, true)); + JSHandle handleEcmaStrBackU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayBackU16NotComp[0], lengthEcmaStrBackU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrConcatU8U16NotComp( + thread, EcmaString::Concat(handleEcmaStrFrontU8, handleEcmaStrBackU16NotComp, ecmaVMPtr)); EXPECT_TRUE(handleEcmaStrConcatU8U16NotComp->IsUtf16()); for (size_t i = 0; i < lengthEcmaStrFrontU8; i++) { EXPECT_EQ(handleEcmaStrConcatU8U16NotComp->At(i), arrayFrontU8[i]); @@ -609,33 +608,33 @@ TEST_F(EcmaStringTest, Concat_003) */ TEST_F(EcmaStringTest, Concat_004) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); /* Concat() after SetCompressedStringsEnabled(false). EcmaString made by CreateFromUtf16( , , , false) and * EcmaString made by CreateFromUtf16( , , , false). */ - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. uint16_t arrayFrontU16NotComp[] = {128, 129, 256, 11100, 65535, 100}; uint16_t arrayBackU16NotComp[] = {88, 768, 1, 270, 345, 333}; uint32_t lengthEcmaStrFrontU16NotComp = sizeof(arrayFrontU16NotComp) / sizeof(arrayFrontU16NotComp[0]); uint32_t lengthEcmaStrBackU16NotComp = sizeof(arrayBackU16NotComp) / sizeof(arrayBackU16NotComp[0]); - JSHandle handleEcmaStrFrontU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayFrontU16NotComp[0], lengthEcmaStrFrontU16NotComp, ecmaVMPtr, false)); - JSHandle handleEcmaStrBackU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayBackU16NotComp[0], lengthEcmaStrBackU16NotComp, ecmaVMPtr, false)); - JSHandle handleEcmaStrConcatU16NotCompAfterSetFalse(thread, - EcmaString::Concat(handleEcmaStrFrontU16NotComp, handleEcmaStrBackU16NotComp, ecmaVMPtr)); + JSHandle handleEcmaStrFrontU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayFrontU16NotComp[0], lengthEcmaStrFrontU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrBackU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayBackU16NotComp[0], lengthEcmaStrBackU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrConcatU16NotCompAfterSetFalse( + thread, EcmaString::Concat(handleEcmaStrFrontU16NotComp, handleEcmaStrBackU16NotComp, ecmaVMPtr)); EXPECT_TRUE(handleEcmaStrConcatU16NotCompAfterSetFalse->IsUtf16()); for (size_t i = 0; i < lengthEcmaStrFrontU16NotComp; i++) { EXPECT_EQ(handleEcmaStrConcatU16NotCompAfterSetFalse->At(i), arrayFrontU16NotComp[i]); } for (size_t i = 0; i < lengthEcmaStrBackU16NotComp; i++) { EXPECT_EQ(handleEcmaStrConcatU16NotCompAfterSetFalse->At(i + lengthEcmaStrFrontU16NotComp), - arrayBackU16NotComp[i]); + arrayBackU16NotComp[i]); } EXPECT_EQ(handleEcmaStrConcatU16NotCompAfterSetFalse->GetLength(), - lengthEcmaStrFrontU16NotComp + lengthEcmaStrBackU16NotComp); - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + lengthEcmaStrFrontU16NotComp + lengthEcmaStrBackU16NotComp); + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -647,17 +646,17 @@ TEST_F(EcmaStringTest, Concat_004) */ TEST_F(EcmaStringTest, FastSubString_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // FastSubString(). From EcmaString made by CreateFromUtf8(). uint8_t arrayU8[6] = {3, 7, 19, 54, 99}; uint32_t lengthEcmaStrU8 = sizeof(arrayU8) - 1; JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); uint32_t indexStartSubU8 = 2; uint32_t lengthSubU8 = 2; - JSHandle handleEcmaStrSubU8(thread, - EcmaString::FastSubString(handleEcmaStrU8, indexStartSubU8, lengthSubU8, ecmaVMPtr)); + JSHandle handleEcmaStrSubU8( + thread, EcmaString::FastSubString(handleEcmaStrU8, indexStartSubU8, lengthSubU8, ecmaVMPtr)); for (size_t i = 0; i < lengthSubU8; i++) { EXPECT_EQ(handleEcmaStrSubU8->At(i), handleEcmaStrU8->At(i + indexStartSubU8)); } @@ -673,17 +672,17 @@ TEST_F(EcmaStringTest, FastSubString_001) */ TEST_F(EcmaStringTest, FastSubString_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // FastSubString(). From EcmaString made by CreateFromUtf16( , , , true). uint16_t arrayU16Comp[] = {1, 12, 34, 56, 127}; uint32_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); uint32_t indexStartSubU16Comp = 0; uint32_t lengthSubU16Comp = 2; - JSHandle handleEcmaStrSubU16Comp(thread, - EcmaString::FastSubString(handleEcmaStrU16Comp, indexStartSubU16Comp, lengthSubU16Comp, ecmaVMPtr)); + JSHandle handleEcmaStrSubU16Comp( + thread, EcmaString::FastSubString(handleEcmaStrU16Comp, indexStartSubU16Comp, lengthSubU16Comp, ecmaVMPtr)); for (size_t i = 0; i < lengthSubU16Comp; i++) { EXPECT_EQ(handleEcmaStrSubU16Comp->At(i), handleEcmaStrU16Comp->At(i + indexStartSubU16Comp)); } @@ -699,16 +698,17 @@ TEST_F(EcmaStringTest, FastSubString_002) */ TEST_F(EcmaStringTest, FastSubString_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // FastSubString(). From EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayU16NotComp[] = {19, 54, 256, 11100, 65535}; uint32_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); uint32_t indexStartSubU16NotComp = 0; uint32_t lengthSubU16NotComp = 2; - JSHandle handleEcmaStrSubU16NotComp(thread, + JSHandle handleEcmaStrSubU16NotComp( + thread, EcmaString::FastSubString(handleEcmaStrU16NotComp, indexStartSubU16NotComp, lengthSubU16NotComp, ecmaVMPtr)); for (size_t i = 0; i < lengthSubU16NotComp; i++) { EXPECT_EQ(handleEcmaStrSubU16NotComp->At(i), handleEcmaStrU16NotComp->At(i + indexStartSubU16NotComp)); @@ -725,20 +725,20 @@ TEST_F(EcmaStringTest, FastSubString_003) */ TEST_F(EcmaStringTest, WriteData_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // WriteData(). From EcmaString made by CreateFromUtf8() to EcmaString made by AllocStringObject( , true, ). uint8_t arrayU8WriteFrom[6] = {1, 12, 34, 56, 127}; uint32_t lengthEcmaStrU8WriteFrom = sizeof(arrayU8WriteFrom) - 1; - JSHandle handleEcmaStrU8WriteFrom(thread, - EcmaString::CreateFromUtf8(&arrayU8WriteFrom[0], lengthEcmaStrU8WriteFrom, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8WriteFrom( + thread, EcmaString::CreateFromUtf8(&arrayU8WriteFrom[0], lengthEcmaStrU8WriteFrom, ecmaVMPtr, true)); size_t sizeEcmaStrU8WriteTo = 5; - JSHandle handleEcmaStrAllocTrueWriteTo(thread, - EcmaString::AllocStringObject(sizeEcmaStrU8WriteTo, true, ecmaVMPtr)); + JSHandle handleEcmaStrAllocTrueWriteTo( + thread, EcmaString::AllocStringObject(sizeEcmaStrU8WriteTo, true, ecmaVMPtr)); uint32_t indexStartWriteFromArrayU8 = 2; uint32_t lengthWriteFromArrayU8 = 2; handleEcmaStrAllocTrueWriteTo->WriteData(*handleEcmaStrU8WriteFrom, indexStartWriteFromArrayU8, - sizeEcmaStrU8WriteTo, lengthWriteFromArrayU8); + sizeEcmaStrU8WriteTo, lengthWriteFromArrayU8); for (size_t i = 0; i < lengthWriteFromArrayU8; i++) { EXPECT_EQ(handleEcmaStrAllocTrueWriteTo->At(i + indexStartWriteFromArrayU8), handleEcmaStrU8WriteFrom->At(i)); } @@ -753,13 +753,13 @@ TEST_F(EcmaStringTest, WriteData_001) */ TEST_F(EcmaStringTest, WriteData_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // WriteData(). From char to EcmaString made by AllocStringObject( , true, ). char u8Write = 'a'; size_t sizeEcmaStrU8WriteTo = 5; - JSHandle handleEcmaStrAllocTrueWriteTo(thread, - EcmaString::AllocStringObject(sizeEcmaStrU8WriteTo, true, ecmaVMPtr)); + JSHandle handleEcmaStrAllocTrueWriteTo( + thread, EcmaString::AllocStringObject(sizeEcmaStrU8WriteTo, true, ecmaVMPtr)); uint32_t indexAtWriteFromU8 = 4; handleEcmaStrAllocTrueWriteTo->WriteData(u8Write, indexAtWriteFromU8); EXPECT_EQ(handleEcmaStrAllocTrueWriteTo->At(indexAtWriteFromU8), u8Write); @@ -774,22 +774,22 @@ TEST_F(EcmaStringTest, WriteData_002) */ TEST_F(EcmaStringTest, WriteData_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); /* WriteData(). From EcmaString made by CreateFromUtf16( , , , false) to EcmaStringU16 made by * AllocStringObject( , false, ). */ uint16_t arrayU16WriteFrom[10] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t lengthEcmaStrU16WriteFrom = sizeof(arrayU16WriteFrom) / sizeof(arrayU16WriteFrom[0]); - JSHandle handleEcmaStrU16WriteFrom(thread, - EcmaString::CreateFromUtf16(&arrayU16WriteFrom[0], lengthEcmaStrU16WriteFrom, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16WriteFrom( + thread, EcmaString::CreateFromUtf16(&arrayU16WriteFrom[0], lengthEcmaStrU16WriteFrom, ecmaVMPtr, false)); size_t sizeEcmaStrU16WriteTo = 10; - JSHandle handleEcmaStrU16WriteTo(thread, - EcmaString::AllocStringObject(sizeEcmaStrU16WriteTo, false, ecmaVMPtr)); + JSHandle handleEcmaStrU16WriteTo( + thread, EcmaString::AllocStringObject(sizeEcmaStrU16WriteTo, false, ecmaVMPtr)); uint32_t indexStartWriteFromArrayU16 = 3; uint32_t numBytesWriteFromArrayU16 = 2 * 3; handleEcmaStrU16WriteTo->WriteData(*handleEcmaStrU16WriteFrom, indexStartWriteFromArrayU16, sizeEcmaStrU16WriteTo, - numBytesWriteFromArrayU16); + numBytesWriteFromArrayU16); for (size_t i = 0; i < (numBytesWriteFromArrayU16 / 2); i++) { EXPECT_EQ(handleEcmaStrU16WriteTo->At(i + indexStartWriteFromArrayU16), handleEcmaStrU16WriteFrom->At(i)); } @@ -804,20 +804,20 @@ TEST_F(EcmaStringTest, WriteData_003) */ TEST_F(EcmaStringTest, WriteData_004) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // WriteData(). From EcmaString made by CreateFromUtf8() to EcmaString made by AllocStringObject( , false, ). uint8_t arrayU8WriteFrom[6] = {1, 12, 34, 56, 127}; uint32_t lengthEcmaStrU8WriteFrom = sizeof(arrayU8WriteFrom) - 1; - JSHandle handleEcmaStrU8WriteFrom(thread, - EcmaString::CreateFromUtf8(&arrayU8WriteFrom[0], lengthEcmaStrU8WriteFrom, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8WriteFrom( + thread, EcmaString::CreateFromUtf8(&arrayU8WriteFrom[0], lengthEcmaStrU8WriteFrom, ecmaVMPtr, true)); size_t sizeEcmaStrU16WriteTo = 10; - JSHandle handleEcmaStrU16WriteTo(thread, - EcmaString::AllocStringObject(sizeEcmaStrU16WriteTo, false, ecmaVMPtr)); + JSHandle handleEcmaStrU16WriteTo( + thread, EcmaString::AllocStringObject(sizeEcmaStrU16WriteTo, false, ecmaVMPtr)); uint32_t indexStartWriteFromU8ToU16 = 1; uint32_t numBytesWriteFromU8ToU16 = 4; handleEcmaStrU16WriteTo->WriteData(*handleEcmaStrU8WriteFrom, indexStartWriteFromU8ToU16, sizeEcmaStrU16WriteTo, - numBytesWriteFromU8ToU16); + numBytesWriteFromU8ToU16); for (size_t i = 0; i < numBytesWriteFromU8ToU16; i++) { EXPECT_EQ(handleEcmaStrU16WriteTo->At(i + indexStartWriteFromU8ToU16), handleEcmaStrU8WriteFrom->At(i)); } @@ -832,12 +832,12 @@ TEST_F(EcmaStringTest, WriteData_004) */ TEST_F(EcmaStringTest, WriteData_005) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // WriteData(). From char to EcmaString made by AllocStringObject( , false, ). size_t sizeEcmaStrU16WriteTo = 10; - JSHandle handleEcmaStrU16WriteTo(thread, - EcmaString::AllocStringObject(sizeEcmaStrU16WriteTo, false, ecmaVMPtr)); + JSHandle handleEcmaStrU16WriteTo( + thread, EcmaString::AllocStringObject(sizeEcmaStrU16WriteTo, false, ecmaVMPtr)); char u8Write = 'a'; uint32_t indexAt = 4; handleEcmaStrU16WriteTo->WriteData(u8Write, indexAt); @@ -852,7 +852,7 @@ TEST_F(EcmaStringTest, WriteData_005) */ TEST_F(EcmaStringTest, GetUtf8Length) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); uint8_t arrayU8[6] = {3, 7, 19, 54, 99}; uint16_t arrayU16Comp[] = {1, 12, 34, 56, 127}; uint16_t arrayU16NotComp[] = {19, 54, 256, 11100, 65535}; @@ -860,11 +860,11 @@ TEST_F(EcmaStringTest, GetUtf8Length) uint32_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); uint32_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU8->GetUtf8Length(), lengthEcmaStrU8 + 1); EXPECT_EQ(handleEcmaStrU16Comp->GetUtf8Length(), lengthEcmaStrU16Comp + 1); EXPECT_EQ(handleEcmaStrU16NotComp->GetUtf8Length(), 2 * lengthEcmaStrU16NotComp + 1); @@ -878,7 +878,7 @@ TEST_F(EcmaStringTest, GetUtf8Length) */ TEST_F(EcmaStringTest, GetUtf16Length) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); uint8_t arrayU8[6] = {3, 7, 19, 54, 99}; uint16_t arrayU16Comp[] = {1, 12, 34, 56, 127}; @@ -887,11 +887,11 @@ TEST_F(EcmaStringTest, GetUtf16Length) uint32_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); uint32_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU8->GetUtf16Length(), lengthEcmaStrU8); EXPECT_EQ(handleEcmaStrU16Comp->GetUtf16Length(), lengthEcmaStrU16Comp); EXPECT_EQ(handleEcmaStrU16NotComp->GetUtf16Length(), lengthEcmaStrU16NotComp); @@ -905,22 +905,22 @@ TEST_F(EcmaStringTest, GetUtf16Length) */ TEST_F(EcmaStringTest, GetDataUtf8) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // From EcmaString made by CreateFromUtf8(). uint8_t arrayU8[] = {"abcde"}; uint32_t lengthEcmaStrU8 = sizeof(arrayU8) - 1; JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); - for (size_t i =0; i < lengthEcmaStrU8; i++) { + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + for (size_t i = 0; i < lengthEcmaStrU8; i++) { EXPECT_EQ(*(handleEcmaStrU8->GetDataUtf8() + i), arrayU8[i]); } // From EcmaString made by CreateFromUtf16( , , , true). uint16_t arrayU16Comp[] = {3, 1, 34, 123, 127, 111, 42, 3, 20, 10}; uint32_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); for (size_t i = 0; i < sizeof(arrayU16Comp) / arrayU16Comp[0]; i++) { EXPECT_EQ(*(handleEcmaStrU16Comp->GetDataUtf8() + i), arrayU16Comp[i]); } @@ -934,13 +934,13 @@ TEST_F(EcmaStringTest, GetDataUtf8) */ TEST_F(EcmaStringTest, GetDataUtf16) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // From EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayU16NotComp[] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); for (size_t i = 0; i < lengthEcmaStrU16NotComp; i++) { EXPECT_EQ(*(handleEcmaStrU16NotComp->GetDataUtf16() + i), arrayU16NotComp[i]); } @@ -955,13 +955,13 @@ TEST_F(EcmaStringTest, GetDataUtf16) */ TEST_F(EcmaStringTest, CopyDataRegionUtf8) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // CopyDataRegionUtf8(). From EcmaString made by CreateFromUtf8(). uint8_t arrayU8CopyFrom[6] = {1, 12, 34, 56, 127}; uint32_t lengthEcmaStrU8CopyFrom = sizeof(arrayU8CopyFrom) - 1; - JSHandle handleEcmaStrU8CopyFrom(thread, - EcmaString::CreateFromUtf8(&arrayU8CopyFrom[0], lengthEcmaStrU8CopyFrom, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8CopyFrom( + thread, EcmaString::CreateFromUtf8(&arrayU8CopyFrom[0], lengthEcmaStrU8CopyFrom, ecmaVMPtr, true)); const size_t lengthArrayU8Target = 7; uint8_t defaultByteForU8CopyTo = 1; uint8_t arrayU8CopyTo[lengthArrayU8Target]; @@ -970,7 +970,7 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf8) size_t indexStartFromArrayU8 = 2; size_t lengthCopyToEcmaStrU8 = 3; size_t lengthReturnU8 = handleEcmaStrU8CopyFrom->CopyDataRegionUtf8(arrayU8CopyTo, indexStartFromArrayU8, - lengthCopyToEcmaStrU8, lengthArrayU8Target); + lengthCopyToEcmaStrU8, lengthArrayU8Target); EXPECT_EQ(lengthReturnU8, lengthCopyToEcmaStrU8); for (size_t i = 0; i < lengthCopyToEcmaStrU8; i++) { @@ -983,8 +983,8 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf8) // CopyDataRegionUtf8(). From EcmaString made by CreateFromUtf16( , , , true). uint16_t arrayU16CompCopyFrom[] = {1, 12, 34, 56, 127}; uint32_t lengthEcmaStrU16CompCopyFrom = sizeof(arrayU16CompCopyFrom) / sizeof(arrayU16CompCopyFrom[0]); - JSHandle handleEcmaStrU16CompCopyFrom(thread, - EcmaString::CreateFromUtf16(&arrayU16CompCopyFrom[0], lengthEcmaStrU16CompCopyFrom, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompCopyFrom( + thread, EcmaString::CreateFromUtf16(&arrayU16CompCopyFrom[0], lengthEcmaStrU16CompCopyFrom, ecmaVMPtr, true)); const size_t lengthArrayU16Target = 8; uint8_t defaultByteForU16CompCopyTo = 1; uint8_t arrayU16CompCopyTo[lengthArrayU16Target]; @@ -992,8 +992,8 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf8) size_t indexStartFromArrayU16Comp = 2; size_t lengthCopyToEcmaStrU16Comp = 3; - size_t lengthReturnU16Comp = handleEcmaStrU16CompCopyFrom->CopyDataRegionUtf8(&arrayU16CompCopyTo[0], - indexStartFromArrayU16Comp, lengthCopyToEcmaStrU16Comp, lengthArrayU16Target); + size_t lengthReturnU16Comp = handleEcmaStrU16CompCopyFrom->CopyDataRegionUtf8( + &arrayU16CompCopyTo[0], indexStartFromArrayU16Comp, lengthCopyToEcmaStrU16Comp, lengthArrayU16Target); EXPECT_EQ(lengthReturnU16Comp, lengthCopyToEcmaStrU16Comp); for (size_t i = 0; i < lengthReturnU16Comp; i++) { @@ -1013,13 +1013,13 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf8) */ TEST_F(EcmaStringTest, CopyDataUtf8) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // CopyDataUtf8(). From EcmaString made by CreateFromUtf8(). uint8_t arrayU8CopyFrom[6] = {1, 12, 34, 56, 127}; uint32_t lengthEcmaStrU8CopyFrom = sizeof(arrayU8CopyFrom) - 1; - JSHandle handleEcmaStrU8CopyFrom(thread, - EcmaString::CreateFromUtf8(&arrayU8CopyFrom[0], lengthEcmaStrU8CopyFrom, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8CopyFrom( + thread, EcmaString::CreateFromUtf8(&arrayU8CopyFrom[0], lengthEcmaStrU8CopyFrom, ecmaVMPtr, true)); const size_t lengthArrayU8Target = 6; uint8_t arrayU8CopyTo[lengthArrayU8Target]; @@ -1034,13 +1034,13 @@ TEST_F(EcmaStringTest, CopyDataUtf8) // CopyDataUtf8(). From EcmaString made by CreateFromUtf16( , , , true). uint16_t arrayU16CompCopyFrom[] = {1, 12, 34, 56, 127}; uint32_t lengthEcmaStrU16CompCopyFrom = sizeof(arrayU16CompCopyFrom) / sizeof(arrayU16CompCopyFrom[0]); - JSHandle handleEcmaStrU16CompCopyFrom(thread, - EcmaString::CreateFromUtf16(&arrayU16CompCopyFrom[0], lengthEcmaStrU16CompCopyFrom, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompCopyFrom( + thread, EcmaString::CreateFromUtf16(&arrayU16CompCopyFrom[0], lengthEcmaStrU16CompCopyFrom, ecmaVMPtr, true)); const size_t lengthArrayU16Target = 6; uint8_t arrayU8CompCopyTo[lengthArrayU16Target]; - size_t lengthReturnU16Comp = handleEcmaStrU16CompCopyFrom->CopyDataUtf8(&arrayU8CompCopyTo[0], - lengthArrayU16Target); + size_t lengthReturnU16Comp = + handleEcmaStrU16CompCopyFrom->CopyDataUtf8(&arrayU8CompCopyTo[0], lengthArrayU16Target); EXPECT_EQ(lengthReturnU16Comp, lengthArrayU16Target); for (size_t i = 0; i < lengthReturnU16Comp - 1; i++) { @@ -1058,23 +1058,24 @@ TEST_F(EcmaStringTest, CopyDataUtf8) */ TEST_F(EcmaStringTest, CopyDataRegionUtf16) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // CopyDataRegionUtf16(). From EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayU16NotCompCopyFrom[10] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t lengthEcmaStrU16NotCompCopyFrom = sizeof(arrayU16NotCompCopyFrom) / sizeof(arrayU16NotCompCopyFrom[0]); - JSHandle handleEcmaStrU16NotCompCopyFrom(thread, + JSHandle handleEcmaStrU16NotCompCopyFrom( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompCopyFrom[0], lengthEcmaStrU16NotCompCopyFrom, ecmaVMPtr, false)); const size_t lengthArrayU16Target = 13; uint16_t arrayU16NotCompCopyTo[lengthArrayU16Target]; uint8_t defaultOneByteValueOfArrayU16NotCompCopyTo = 244; memset_s(&arrayU16NotCompCopyTo[0], sizeof(uint16_t) * lengthArrayU16Target, - defaultOneByteValueOfArrayU16NotCompCopyTo, sizeof(uint16_t) * lengthArrayU16Target); + defaultOneByteValueOfArrayU16NotCompCopyTo, sizeof(uint16_t) * lengthArrayU16Target); size_t startIndexFromArrayU16NotComp = 2; size_t lengthCopyFromArrayU16NotComp = 3; - size_t lengthReturnU16NotComp = handleEcmaStrU16NotCompCopyFrom->CopyDataRegionUtf16(&arrayU16NotCompCopyTo[0], - startIndexFromArrayU16NotComp, lengthCopyFromArrayU16NotComp, lengthArrayU16Target); + size_t lengthReturnU16NotComp = handleEcmaStrU16NotCompCopyFrom->CopyDataRegionUtf16( + &arrayU16NotCompCopyTo[0], startIndexFromArrayU16NotComp, lengthCopyFromArrayU16NotComp, lengthArrayU16Target); EXPECT_EQ(lengthReturnU16NotComp, lengthCopyFromArrayU16NotComp); for (size_t i = 0; i < lengthReturnU16NotComp; i++) { @@ -1094,21 +1095,22 @@ TEST_F(EcmaStringTest, CopyDataRegionUtf16) */ TEST_F(EcmaStringTest, CopyDataUtf16) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // CopyDataUtf16(). From EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayU16NotCompCopyFrom[10] = {67, 777, 1999, 1, 45, 66, 23456, 65535, 127, 333}; uint32_t lengthEcmaStrU16NotCompCopyFrom = sizeof(arrayU16NotCompCopyFrom) / sizeof(arrayU16NotCompCopyFrom[0]); - JSHandle handleEcmaStrU16NotCompCopyFrom(thread, + JSHandle handleEcmaStrU16NotCompCopyFrom( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompCopyFrom[0], lengthEcmaStrU16NotCompCopyFrom, ecmaVMPtr, false)); const size_t lengthArrayU16Target = 13; uint16_t arrayU16NotCompCopyTo[lengthArrayU16Target]; uint8_t defaultOneByteValueOfArrayU16NotCompCopyTo = 244; memset_s(&arrayU16NotCompCopyTo[0], sizeof(uint16_t) * lengthArrayU16Target, - defaultOneByteValueOfArrayU16NotCompCopyTo, sizeof(uint16_t) * lengthArrayU16Target); + defaultOneByteValueOfArrayU16NotCompCopyTo, sizeof(uint16_t) * lengthArrayU16Target); - size_t lengthReturnU16NotComp = handleEcmaStrU16NotCompCopyFrom->CopyDataUtf16(&arrayU16NotCompCopyTo[0], - lengthArrayU16Target); + size_t lengthReturnU16NotComp = + handleEcmaStrU16NotCompCopyFrom->CopyDataUtf16(&arrayU16NotCompCopyTo[0], lengthArrayU16Target); EXPECT_EQ(lengthReturnU16NotComp, lengthEcmaStrU16NotCompCopyFrom); for (size_t i = 0; i < lengthReturnU16NotComp; i++) { @@ -1128,17 +1130,17 @@ TEST_F(EcmaStringTest, CopyDataUtf16) */ TEST_F(EcmaStringTest, IndexOf_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // IndexOf(). Find EcmaString made by CreateFromUtf8() From EcmaString made by CreateFromUtf8(). uint8_t arrayU8From[7] = {23, 25, 1, 3, 39, 80}; uint8_t arrayU8Target[4] = {1, 3, 39}; uint32_t lengthEcmaStrU8From = sizeof(arrayU8From) - 1; uint32_t lengthEcmaStrU8Target = sizeof(arrayU8Target) - 1; - JSHandle handleEcmaStr(thread, EcmaString::CreateFromUtf8(&arrayU8From[0], lengthEcmaStrU8From, - ecmaVMPtr, true)); - JSHandle handleEcmaStr1(thread, EcmaString::CreateFromUtf8(&arrayU8Target[0], lengthEcmaStrU8Target, - ecmaVMPtr, true)); + JSHandle handleEcmaStr( + thread, EcmaString::CreateFromUtf8(&arrayU8From[0], lengthEcmaStrU8From, ecmaVMPtr, true)); + JSHandle handleEcmaStr1( + thread, EcmaString::CreateFromUtf8(&arrayU8Target[0], lengthEcmaStrU8Target, ecmaVMPtr, true)); int32_t posStart = 0; EXPECT_EQ(handleEcmaStr->IndexOf(*handleEcmaStr1, posStart), 2); EXPECT_EQ(handleEcmaStr1->IndexOf(*handleEcmaStr, posStart), -1); @@ -1161,16 +1163,17 @@ TEST_F(EcmaStringTest, IndexOf_001) */ TEST_F(EcmaStringTest, IndexOf_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // IndexOf(). Find EcmaString made by CreateFromUtf8() From EcmaString made by CreateFromUtf16( , , , false). uint8_t arrayU8Target[4] = {1, 3, 39}; uint16_t arrayU16NotCompFromNo1[] = {67, 65535, 127, 777, 1453, 44, 1, 3, 39, 80, 333}; uint32_t lengthEcmaStrU8Target = sizeof(arrayU8Target) - 1; uint32_t lengthEcmaStrU16NotCompFromNo1 = sizeof(arrayU16NotCompFromNo1) / sizeof(arrayU16NotCompFromNo1[0]); - JSHandle handleEcmaStr(thread, - EcmaString::CreateFromUtf8(&arrayU8Target[0], lengthEcmaStrU8Target, ecmaVMPtr, true)); - JSHandle handleEcmaStr1(thread, + JSHandle handleEcmaStr( + thread, EcmaString::CreateFromUtf8(&arrayU8Target[0], lengthEcmaStrU8Target, ecmaVMPtr, true)); + JSHandle handleEcmaStr1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompFromNo1[0], lengthEcmaStrU16NotCompFromNo1, ecmaVMPtr, false)); int32_t posStart = 0; EXPECT_EQ(handleEcmaStr1->IndexOf(*handleEcmaStr, posStart), 6); @@ -1194,7 +1197,7 @@ TEST_F(EcmaStringTest, IndexOf_002) */ TEST_F(EcmaStringTest, IndexOf_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); /* IndexOf(). Find EcmaString made by CreateFromUtf16( , , , false) From EcmaString made by * CreateFromUtf16( , , , false). @@ -1203,10 +1206,11 @@ TEST_F(EcmaStringTest, IndexOf_003) uint16_t arrayU16NotCompFrom[] = {67, 65535, 127, 777, 1453, 44, 1, 3, 39, 80, 333}; uint32_t lengthEcmaStrU16NotCompTarget = sizeof(arrayU16NotCompTarget) / sizeof(arrayU16NotCompTarget[0]); uint32_t lengthEcmaStrU16NotCompFrom = sizeof(arrayU16NotCompFrom) / sizeof(arrayU16NotCompFrom[0]); - JSHandle handleEcmaStrU16NotCompTarget(thread, + JSHandle handleEcmaStrU16NotCompTarget( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompTarget[0], lengthEcmaStrU16NotCompTarget, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompFrom(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompFrom[0], lengthEcmaStrU16NotCompFrom, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompFrom( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompFrom[0], lengthEcmaStrU16NotCompFrom, ecmaVMPtr, false)); int32_t posStart = 0; EXPECT_EQ(handleEcmaStrU16NotCompFrom->IndexOf(*handleEcmaStrU16NotCompTarget, posStart), 4); EXPECT_EQ(handleEcmaStrU16NotCompTarget->IndexOf(*handleEcmaStrU16NotCompFrom, posStart), -1); @@ -1229,17 +1233,18 @@ TEST_F(EcmaStringTest, IndexOf_003) */ TEST_F(EcmaStringTest, IndexOf_004) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // IndexOf(). Find EcmaString made by CreateFromUtf16( , , , false) From EcmaString made by CreateFromUtf8(). uint16_t ecmaStrU16NotCompTarget[] = {3, 39, 80}; uint8_t arrayU8From[7] = {23, 25, 1, 3, 39, 80}; uint32_t lengthEcmaStrU16NotCompTarget = sizeof(ecmaStrU16NotCompTarget) / sizeof(ecmaStrU16NotCompTarget[0]); uint32_t lengthEcmaStrU8From = sizeof(arrayU8From) - 1; - JSHandle handleEcmaStrU16NotCompTarget(thread, + JSHandle handleEcmaStrU16NotCompTarget( + thread, EcmaString::CreateFromUtf16(&ecmaStrU16NotCompTarget[0], lengthEcmaStrU16NotCompTarget, ecmaVMPtr, false)); - JSHandle handleEcmaStrU8From(thread, - EcmaString::CreateFromUtf8(&arrayU8From[0], lengthEcmaStrU8From, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8From( + thread, EcmaString::CreateFromUtf8(&arrayU8From[0], lengthEcmaStrU8From, ecmaVMPtr, true)); int32_t posStart = 0; EXPECT_EQ(handleEcmaStrU8From->IndexOf(*handleEcmaStrU16NotCompTarget, posStart), 3); EXPECT_EQ(handleEcmaStrU16NotCompTarget->IndexOf(*handleEcmaStrU8From, posStart), -1); @@ -1262,7 +1267,7 @@ TEST_F(EcmaStringTest, IndexOf_004) */ TEST_F(EcmaStringTest, StringsAreEqual_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqual(). uint8_t arrayU8No1[4] = {45, 92, 78}; @@ -1271,12 +1276,12 @@ TEST_F(EcmaStringTest, StringsAreEqual_001) uint32_t lengthEcmaStrU8No1 = sizeof(arrayU8No1) - 1; uint32_t lengthEcmaStrU8No2 = sizeof(arrayU8No2) - 1; uint32_t lengthEcmaStrU8No3 = sizeof(arrayU8No3) - 1; - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No2(thread, - EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No3(thread, - EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No2( + thread, EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No3( + thread, EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handleEcmaStrU8No1, *handleEcmaStrU8No2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU8No1, *handleEcmaStrU8No3)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU8No3, *handleEcmaStrU8No1)); @@ -1291,7 +1296,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_001) */ TEST_F(EcmaStringTest, StringsAreEqual_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqual(). uint8_t arrayU8No1[4] = {45, 92, 78}; @@ -1300,12 +1305,12 @@ TEST_F(EcmaStringTest, StringsAreEqual_002) uint32_t lengthEcmaStrU8No1 = sizeof(arrayU8No1) - 1; uint32_t lengthEcmaStrU16CompNo2 = sizeof(arrayU16CompNo2) / sizeof(arrayU16CompNo2[0]); uint32_t lengthEcmaStrU16CompNo3 = sizeof(arrayU16CompNo3) / sizeof(arrayU16CompNo3[0]); - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handleEcmaStrU8No1, *handleEcmaStrU16CompNo2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU8No1, *handleEcmaStrU16CompNo3)); } @@ -1319,7 +1324,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_002) */ TEST_F(EcmaStringTest, StringsAreEqual_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqual(). uint16_t arrayU16CompNo1[] = {45, 92, 78}; @@ -1328,12 +1333,12 @@ TEST_F(EcmaStringTest, StringsAreEqual_003) uint32_t lengthEcmaStrU16CompNo1 = sizeof(arrayU16CompNo1) / sizeof(arrayU16CompNo1[0]); uint32_t lengthEcmaStrU16CompNo2 = sizeof(arrayU16CompNo2) / sizeof(arrayU16CompNo2[0]); uint32_t lengthEcmaStrU16CompNo3 = sizeof(arrayU16CompNo3) / sizeof(arrayU16CompNo3[0]); - JSHandle handleEcmaStrU16CompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handleEcmaStrU16CompNo1, *handleEcmaStrU16CompNo2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU16CompNo1, *handleEcmaStrU16CompNo3)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU16CompNo3, *handleEcmaStrU16CompNo1)); @@ -1348,17 +1353,17 @@ TEST_F(EcmaStringTest, StringsAreEqual_003) */ TEST_F(EcmaStringTest, StringsAreEqual_004) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqual(). uint8_t arrayU8No1[4] = {45, 92, 78}; uint16_t arrayU16NotCompNo1[] = {45, 92, 78}; uint32_t lengthEcmaStrU8No1 = sizeof(arrayU8No1) - 1; uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU8No1, *handleEcmaStrU16NotCompNo1)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU16NotCompNo1, *handleEcmaStrU8No1)); } @@ -1372,17 +1377,17 @@ TEST_F(EcmaStringTest, StringsAreEqual_004) */ TEST_F(EcmaStringTest, StringsAreEqual_005) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqual(). uint16_t arrayU16CompNo1[] = {45, 92, 78}; uint16_t arrayU16NotCompNo1[] = {45, 92, 78}; uint32_t lengthEcmaStrU16CompNo1 = sizeof(arrayU16CompNo1) / sizeof(arrayU16CompNo1[0]); uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); - JSHandle handleEcmaStrU16CompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16CompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU16CompNo1, *handleEcmaStrU16NotCompNo1)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU16NotCompNo1, *handleEcmaStrU16CompNo1)); } @@ -1396,7 +1401,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_005) */ TEST_F(EcmaStringTest, StringsAreEqual_006) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqual(). uint16_t arrayU16NotCompNo1[] = {234, 345, 127, 2345, 65535, 5}; @@ -1405,12 +1410,12 @@ TEST_F(EcmaStringTest, StringsAreEqual_006) uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); uint32_t lengthEcmaStrU16NotCompNo2 = sizeof(arrayU16NotCompNo2) / sizeof(arrayU16NotCompNo2[0]); uint32_t lengthEcmaStrU16NotCompNo3 = sizeof(arrayU16NotCompNo3) / sizeof(arrayU16NotCompNo3[0]); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); EXPECT_TRUE(EcmaString::StringsAreEqual(*handleEcmaStrU16NotCompNo1, *handleEcmaStrU16NotCompNo2)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU16NotCompNo1, *handleEcmaStrU16NotCompNo3)); EXPECT_FALSE(EcmaString::StringsAreEqual(*handleEcmaStrU16NotCompNo3, *handleEcmaStrU16NotCompNo1)); @@ -1425,7 +1430,7 @@ TEST_F(EcmaStringTest, StringsAreEqual_006) */ TEST_F(EcmaStringTest, StringsAreEqualUtf8_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqualUtf8(). EcmaString made by CreateFromUtf8(), Array:U8. uint8_t arrayU8No1[4] = {45, 92, 78}; @@ -1434,12 +1439,12 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_001) uint32_t lengthEcmaStrU8No1 = sizeof(arrayU8No1) - 1; uint32_t lengthEcmaStrU8No2 = sizeof(arrayU8No2) - 1; uint32_t lengthEcmaStrU8No3 = sizeof(arrayU8No3) - 1; - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No2(thread, - EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No3(thread, - EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No2( + thread, EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No3( + thread, EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); EXPECT_TRUE(EcmaString::StringsAreEqualUtf8(*handleEcmaStrU8No1, &arrayU8No1[0], lengthEcmaStrU8No1, true)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf8(*handleEcmaStrU8No1, &arrayU8No1[0], lengthEcmaStrU8No1, false)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf8(*handleEcmaStrU8No2, &arrayU8No1[0], lengthEcmaStrU8No1, true)); @@ -1455,7 +1460,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_001) */ TEST_F(EcmaStringTest, StringsAreEqualUtf8_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqualUtf8(). EcmaString made by CreateFromUtf16( , , , true), Array:U8. uint8_t arrayU8No1[4] = {45, 92, 78}; @@ -1466,12 +1471,12 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_002) uint32_t lengthEcmaStrU16CompNo1 = sizeof(arrayU16CompNo1) / sizeof(arrayU16CompNo1[0]); uint32_t lengthEcmaStrU16CompNo2 = sizeof(arrayU16CompNo2) / sizeof(arrayU16CompNo2[0]); uint32_t lengthEcmaStrU16CompNo3 = sizeof(arrayU16CompNo3) / sizeof(arrayU16CompNo3[0]); - JSHandle handleEcmaStrU16CompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); EXPECT_TRUE(EcmaString::StringsAreEqualUtf8(*handleEcmaStrU16CompNo1, &arrayU8No1[0], lengthEcmaStrU8No1, true)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf8(*handleEcmaStrU16CompNo1, &arrayU8No1[0], lengthEcmaStrU8No1, false)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf8(*handleEcmaStrU16CompNo2, &arrayU8No1[0], lengthEcmaStrU8No1, true)); @@ -1487,7 +1492,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_002) */ TEST_F(EcmaStringTest, StringsAreEqualUtf8_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqualUtf8(). EcmaString made by CreateFromUtf16( , , , false), Array:U8. uint8_t arrayU8No1[4] = {45, 92, 78}; @@ -1500,14 +1505,14 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_003) uint32_t lengthEcmaStrU16NotCompNo2 = sizeof(arrayU16NotCompNo2) / sizeof(arrayU16NotCompNo2[0]); uint32_t lengthEcmaStrU16NotCompNo3 = sizeof(arrayU16NotCompNo3) / sizeof(arrayU16NotCompNo3[0]); uint32_t lengthEcmaStrU16NotCompNo4 = sizeof(arrayU16NotCompNo4) / sizeof(arrayU16NotCompNo4[0]); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo4(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo4[0], lengthEcmaStrU16NotCompNo4, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo4( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo4[0], lengthEcmaStrU16NotCompNo4, ecmaVMPtr, false)); EXPECT_TRUE( EcmaString::StringsAreEqualUtf8(*handleEcmaStrU16NotCompNo1, &arrayU8No1[0], lengthEcmaStrU8No1, false)); EXPECT_FALSE( @@ -1529,7 +1534,7 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf8_003) */ TEST_F(EcmaStringTest, StringsAreEqualUtf16_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqualUtf16(). EcmaString made by CreateFromUtf8, Array:U16(1-127). uint8_t arrayU8No1[4] = {45, 92, 78}; @@ -1540,12 +1545,12 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_001) uint32_t lengthEcmaStrU8No2 = sizeof(arrayU8No2) - 1; uint32_t lengthEcmaStrU8No3 = sizeof(arrayU8No3) - 1; uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); - JSHandle handleEcmaStrU8No1(thread, - EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No2(thread, - EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU8No3(thread, - EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No1( + thread, EcmaString::CreateFromUtf8(&arrayU8No1[0], lengthEcmaStrU8No1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No2( + thread, EcmaString::CreateFromUtf8(&arrayU8No2[0], lengthEcmaStrU8No2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU8No3( + thread, EcmaString::CreateFromUtf8(&arrayU8No3[0], lengthEcmaStrU8No3, ecmaVMPtr, true)); EXPECT_TRUE( EcmaString::StringsAreEqualUtf16(*handleEcmaStrU8No1, &arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1)); EXPECT_FALSE( @@ -1563,25 +1568,25 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_001) */ TEST_F(EcmaStringTest, StringsAreEqualUtf16_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqualUtf16(). EcmaString made by CreateFromUtf16( , , , true), Array:U16(1-127). uint16_t arrayU16CompNo1[] = {45, 92, 78}; uint16_t arrayU16CompNo2[] = {45, 92, 78, 24}; uint16_t arrayU16CompNo3[] = {45, 92}; - uint16_t arrayU16CompNo4[] = {25645, 25692, 25678}; // 25645 % 256 == 45... + uint16_t arrayU16CompNo4[] = {25645, 25692, 25678}; // 25645 % 256 == 45... uint32_t lengthEcmaStrU16CompNo1 = sizeof(arrayU16CompNo1) / sizeof(arrayU16CompNo1[0]); uint32_t lengthEcmaStrU16CompNo2 = sizeof(arrayU16CompNo2) / sizeof(arrayU16CompNo2[0]); uint32_t lengthEcmaStrU16CompNo3 = sizeof(arrayU16CompNo3) / sizeof(arrayU16CompNo3[0]); uint32_t lengthEcmaStrU16CompNo4 = sizeof(arrayU16CompNo4) / sizeof(arrayU16CompNo4[0]); - JSHandle handleEcmaStrU16CompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); - JSHandle handleEcmaStrU16CompNo4(thread, - EcmaString::CreateFromUtf16(&arrayU16CompNo4[0], lengthEcmaStrU16CompNo4, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo1[0], lengthEcmaStrU16CompNo1, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo2[0], lengthEcmaStrU16CompNo2, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo3[0], lengthEcmaStrU16CompNo3, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16CompNo4( + thread, EcmaString::CreateFromUtf16(&arrayU16CompNo4[0], lengthEcmaStrU16CompNo4, ecmaVMPtr, true)); EXPECT_TRUE( EcmaString::StringsAreEqualUtf16(*handleEcmaStrU16CompNo1, &arrayU16CompNo1[0], lengthEcmaStrU16CompNo1)); EXPECT_FALSE( @@ -1601,35 +1606,35 @@ TEST_F(EcmaStringTest, StringsAreEqualUtf16_002) */ TEST_F(EcmaStringTest, StringsAreEqualUtf16_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // StringsAreEqualUtf16(). EcmaString made by CreateFromUtf16( , , , false), Array:U16(0-65535). uint16_t arrayU16NotCompNo1[] = {25645, 25692, 25678}; - uint16_t arrayU16NotCompNo2[] = {25645, 25692, 78}; // 25645 % 256 == 45... + uint16_t arrayU16NotCompNo2[] = {25645, 25692, 78}; // 25645 % 256 == 45... uint16_t arrayU16NotCompNo3[] = {25645, 25692, 25678, 65535}; uint16_t arrayU16NotCompNo4[] = {25645, 25692}; uint32_t lengthEcmaStrU16NotCompNo1 = sizeof(arrayU16NotCompNo1) / sizeof(arrayU16NotCompNo1[0]); uint32_t lengthEcmaStrU16NotCompNo2 = sizeof(arrayU16NotCompNo2) / sizeof(arrayU16NotCompNo2[0]); uint32_t lengthEcmaStrU16NotCompNo3 = sizeof(arrayU16NotCompNo3) / sizeof(arrayU16NotCompNo3[0]); uint32_t lengthEcmaStrU16NotCompNo4 = sizeof(arrayU16NotCompNo4) / sizeof(arrayU16NotCompNo4[0]); - JSHandle handleEcmaStrU16NotCompNo1(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo2(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo3(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); - JSHandle handleEcmaStrU16NotCompNo4(thread, - EcmaString::CreateFromUtf16(&arrayU16NotCompNo4[0], lengthEcmaStrU16NotCompNo4, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo1( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo2( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo2[0], lengthEcmaStrU16NotCompNo2, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo3( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo3[0], lengthEcmaStrU16NotCompNo3, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotCompNo4( + thread, EcmaString::CreateFromUtf16(&arrayU16NotCompNo4[0], lengthEcmaStrU16NotCompNo4, ecmaVMPtr, false)); EXPECT_TRUE(EcmaString::StringsAreEqualUtf16(*handleEcmaStrU16NotCompNo1, &arrayU16NotCompNo1[0], - lengthEcmaStrU16NotCompNo1)); + lengthEcmaStrU16NotCompNo1)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf16(*handleEcmaStrU16NotCompNo1, &arrayU16NotCompNo2[0], - lengthEcmaStrU16NotCompNo2)); + lengthEcmaStrU16NotCompNo2)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf16(*handleEcmaStrU16NotCompNo2, &arrayU16NotCompNo1[0], - lengthEcmaStrU16NotCompNo1)); + lengthEcmaStrU16NotCompNo1)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf16(*handleEcmaStrU16NotCompNo3, &arrayU16NotCompNo1[0], - lengthEcmaStrU16NotCompNo1)); + lengthEcmaStrU16NotCompNo1)); EXPECT_FALSE(EcmaString::StringsAreEqualUtf16(*handleEcmaStrU16NotCompNo4, &arrayU16NotCompNo1[0], - lengthEcmaStrU16NotCompNo1)); + lengthEcmaStrU16NotCompNo1)); } /* @@ -1677,13 +1682,13 @@ TEST_F(EcmaStringTest, ComputeHashcodeUtf16) */ TEST_F(EcmaStringTest, GetHashcode_001) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // GetHashcode(). EcmaString made by CreateFromUtf8(). uint8_t arrayU8[] = {"abc"}; uint32_t lengthEcmaStrU8 = sizeof(arrayU8) - 1; JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); uint32_t hashExpect = 0; for (uint32_t i = 0; i < lengthEcmaStrU8; i++) { hashExpect = hashExpect * 31 + arrayU8[i]; @@ -1700,13 +1705,13 @@ TEST_F(EcmaStringTest, GetHashcode_001) */ TEST_F(EcmaStringTest, GetHashcode_002) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // GetHashcode(). EcmaString made by CreateFromUtf16( , , , true). uint16_t arrayU16Comp[] = {45, 92, 78, 24}; uint32_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); uint32_t hashExpect = 0; for (uint32_t i = 0; i < lengthEcmaStrU16Comp; i++) { hashExpect = hashExpect * 31 + arrayU16Comp[i]; @@ -1724,24 +1729,24 @@ TEST_F(EcmaStringTest, GetHashcode_002) */ TEST_F(EcmaStringTest, GetHashcode_003) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // GetHashcode(). EcmaString made by CreateFromUtf16( , , , false). uint16_t arrayU16NotComp[] = {199, 1, 256, 65535, 777}; uint32_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); uint32_t hashExpect = 0; for (uint32_t i = 0; i < lengthEcmaStrU16NotComp; i++) { hashExpect = hashExpect * 31 + arrayU16NotComp[i]; } EXPECT_EQ(handleEcmaStrU16NotComp->GetHashcode(), static_cast(hashExpect)); - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. - JSHandle handleEcmaStrU16NotCompDisableComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + JSHandle handleEcmaStrU16NotCompDisableComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_EQ(handleEcmaStrU16NotCompDisableComp->GetHashcode(), static_cast(hashExpect)); - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -1753,16 +1758,16 @@ TEST_F(EcmaStringTest, GetHashcode_003) */ TEST_F(EcmaStringTest, GetHashcode_004) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // GetHashcode(). EcmaString made by CreateEmptyString(). JSHandle handleEcmaStrEmpty(thread, EcmaString::CreateEmptyString(ecmaVMPtr)); EXPECT_EQ(handleEcmaStrEmpty->GetHashcode(), 0); - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. JSHandle handleEcmaStrEmptyDisableComp(thread, EcmaString::CreateEmptyString(ecmaVMPtr)); EXPECT_EQ(handleEcmaStrEmptyDisableComp->GetHashcode(), 0); - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -1775,7 +1780,7 @@ TEST_F(EcmaStringTest, GetHashcode_004) */ TEST_F(EcmaStringTest, GetHashcode_005) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); // GetHashcode(). EcmaString made by AllocStringObject(). size_t sizeAlloc = 5; @@ -1784,11 +1789,11 @@ TEST_F(EcmaStringTest, GetHashcode_005) EXPECT_EQ(handleEcmaStrAllocComp->GetHashcode(), 0); EXPECT_EQ(handleEcmaStrAllocNotComp->GetHashcode(), 0); - EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. - JSHandle handleEcmaStrAllocNotCompDisableComp(thread, - EcmaString::AllocStringObject(sizeAlloc, false, ecmaVMPtr)); + EcmaString::SetCompressedStringsEnabled(false); // Set compressedStringsEnabled false. + JSHandle handleEcmaStrAllocNotCompDisableComp( + thread, EcmaString::AllocStringObject(sizeAlloc, false, ecmaVMPtr)); EXPECT_EQ(handleEcmaStrAllocNotCompDisableComp->GetHashcode(), 0); - EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). + EcmaString::SetCompressedStringsEnabled(true); // Set compressedStringsEnabled true(default). } /* @@ -1800,24 +1805,24 @@ TEST_F(EcmaStringTest, GetHashcode_005) */ TEST_F(EcmaStringTest, GetCString) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); uint8_t arrayU8[] = {"abc"}; uint32_t lengthEcmaStrU8 = sizeof(arrayU8) - 1; JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); EXPECT_STREQ(CString(handleEcmaStrU8->GetCString().get()).c_str(), "abc"); uint16_t arrayU16Comp[] = {97, 98, 99}; uint32_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); EXPECT_STREQ(CString(handleEcmaStrU16Comp->GetCString().get()).c_str(), "abc"); uint16_t arrayU16NotComp[] = {97, 98, 99}; uint32_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_STREQ(CString(handleEcmaStrU16NotComp->GetCString().get()).c_str(), "abc"); } @@ -1830,30 +1835,30 @@ TEST_F(EcmaStringTest, GetCString) */ TEST_F(EcmaStringTest, SetIsInternString) { - EcmaVM* ecmaVMPtr = EcmaVM::Cast(instance); + EcmaVM *ecmaVMPtr = EcmaVM::Cast(instance); uint8_t arrayU8[] = {"abc"}; uint32_t lengthEcmaStrU8 = sizeof(arrayU8) - 1; JSHandle handleEcmaStrU8(thread, - EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); + EcmaString::CreateFromUtf8(&arrayU8[0], lengthEcmaStrU8, ecmaVMPtr, true)); EXPECT_FALSE(handleEcmaStrU8->IsInternString()); handleEcmaStrU8->SetIsInternString(); EXPECT_TRUE(handleEcmaStrU8->IsInternString()); uint16_t arrayU16Comp[] = {97, 98, 99}; uint32_t lengthEcmaStrU16Comp = sizeof(arrayU16Comp) / sizeof(arrayU16Comp[0]); - JSHandle handleEcmaStrU16Comp(thread, - EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); + JSHandle handleEcmaStrU16Comp( + thread, EcmaString::CreateFromUtf16(&arrayU16Comp[0], lengthEcmaStrU16Comp, ecmaVMPtr, true)); EXPECT_FALSE(handleEcmaStrU16Comp->IsInternString()); handleEcmaStrU16Comp->SetIsInternString(); EXPECT_TRUE(handleEcmaStrU16Comp->IsInternString()); uint16_t arrayU16NotComp[] = {97, 98, 99}; uint32_t lengthEcmaStrU16NotComp = sizeof(arrayU16NotComp) / sizeof(arrayU16NotComp[0]); - JSHandle handleEcmaStrU16NotComp(thread, - EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); + JSHandle handleEcmaStrU16NotComp( + thread, EcmaString::CreateFromUtf16(&arrayU16NotComp[0], lengthEcmaStrU16NotComp, ecmaVMPtr, false)); EXPECT_FALSE(handleEcmaStrU16NotComp->IsInternString()); handleEcmaStrU16NotComp->SetIsInternString(); EXPECT_TRUE(handleEcmaStrU16NotComp->IsInternString()); } -} // namespace panda::ecmascript +} // namespace panda::test diff --git a/tests/runtime/common/huge_object_test.cpp b/tests/runtime/common/huge_object_test.cpp index 95c12adf4..64c271d05 100644 --- a/tests/runtime/common/huge_object_test.cpp +++ b/tests/runtime/common/huge_object_test.cpp @@ -61,8 +61,7 @@ static JSObject *JSObjectTestCreate(JSThread *thread) EcmaVM *ecmaVM = thread->GetEcmaVM(); auto globalEnv = ecmaVM->GetGlobalEnv(); JSHandle jsFunc = globalEnv->GetObjectFunction(); - JSHandle newObj = - ecmaVM->GetFactory()->NewJSObjectByConstructor(JSHandle(jsFunc), jsFunc); + JSHandle newObj = ecmaVM->GetFactory()->NewJSObjectByConstructor(JSHandle(jsFunc), jsFunc); return *newObj; } #endif @@ -87,14 +86,14 @@ TEST_F(HugeObjectTest, LargeArrayKeep) arrayHandle->Set(thread, 0, newObj.GetTaggedValue()); auto ecmaVm = thread->GetEcmaVM(); EXPECT_EQ(*arrayHandle, reinterpret_cast(array)); - ecmaVm->CollectGarbage(TriggerGCType::SEMI_GC); // Trigger GC. + ecmaVm->CollectGarbage(TriggerGCType::SEMI_GC); // Trigger GC. ecmaVm->CollectGarbage(TriggerGCType::HUGE_GC); // Trigger GC. EXPECT_EQ(*newObj, array->Get(0).GetTaggedObject()); EXPECT_EQ(*arrayHandle, reinterpret_cast(array)); #endif } -TEST_F(HugeObjectTest, DISABLED_MultipleArrays) // TODO(vpukhov) +TEST_F(HugeObjectTest, DISABLED_MultipleArrays) // TODO(vpukhov) { #if !defined(NDEBUG) auto ecmaVm = thread->GetEcmaVM(); diff --git a/tests/runtime/common/js_array_iterator_test.cpp b/tests/runtime/common/js_array_iterator_test.cpp index 0b50dbcd1..a62689caa 100644 --- a/tests/runtime/common/js_array_iterator_test.cpp +++ b/tests/runtime/common/js_array_iterator_test.cpp @@ -63,8 +63,8 @@ TEST_F(JSArrayIteratorTest, SetIteratedArray) uint32_t arrayFrom1[10] = {0, 6, 8, 99, 200, 1, static_cast(-1), static_cast(-199), 33, 100}; uint32_t arrayFrom2[10] = {1111, 3211, 737, 0, 1267, 174, 2763, 832, 11, 93}; - int numArrayFrom1 = sizeof(arrayFrom1)/sizeof(arrayFrom1[0]); - int numArrayFrom2 = sizeof(arrayFrom2)/sizeof(arrayFrom2[0]); + int numArrayFrom1 = sizeof(arrayFrom1) / sizeof(arrayFrom1[0]); + int numArrayFrom2 = sizeof(arrayFrom2) / sizeof(arrayFrom2[0]); JSHandle handleTaggedArrayFrom1(factory->NewTaggedArray(numArrayFrom1)); JSHandle handleTaggedArrayFrom2(factory->NewTaggedArray(numArrayFrom2)); for (int i = 0; i < numArrayFrom1; i++) { @@ -77,14 +77,14 @@ TEST_F(JSArrayIteratorTest, SetIteratedArray) JSHandle handleJSObjectTaggedArrayFrom2(JSArray::CreateArrayFromList(thread, handleTaggedArrayFrom2)); // Call "SetIteratedArray" function through "NewJSArrayIterator" function of "object_factory.cpp". - JSHandle handleJSArrayIter = factory->NewJSArrayIterator(handleJSObjectTaggedArrayFrom1, - IterationKind::KEY); + JSHandle handleJSArrayIter = + factory->NewJSArrayIterator(handleJSObjectTaggedArrayFrom1, IterationKind::KEY); JSHandle handleJSArrayTo1(thread, JSArray::Cast(handleJSArrayIter->GetIteratedArray().GetTaggedObject())); EXPECT_EQ(handleJSArrayTo1->GetArrayLength(), numArrayFrom1); for (int i = 0; i < numArrayFrom1; i++) { EXPECT_EQ(JSArray::FastGetPropertyByValue(thread, JSHandle(handleJSArrayTo1), i)->GetNumber(), - arrayFrom1[i]); + arrayFrom1[i]); } // Call "SetIteratedArray" function in this TEST_F. @@ -94,7 +94,7 @@ TEST_F(JSArrayIteratorTest, SetIteratedArray) EXPECT_EQ(handleJSArrayTo2->GetArrayLength(), numArrayFrom2); for (int i = 0; i < numArrayFrom2; i++) { EXPECT_EQ(JSArray::FastGetPropertyByValue(thread, JSHandle(handleJSArrayTo2), i)->GetNumber(), - arrayFrom2[i]); + arrayFrom2[i]); } } @@ -112,7 +112,7 @@ TEST_F(JSArrayIteratorTest, SetNextIndex) ObjectFactory *factory = ecmaVMPtr->GetFactory(); uint32_t array[10] = {0, 6, 8, 99, 200, 1, static_cast(-1), static_cast(-199), 33, 100}; - int numArray = sizeof(array)/sizeof(array[0]); + int numArray = sizeof(array) / sizeof(array[0]); JSHandle handleTaggedArray(factory->NewTaggedArray(numArray)); for (int i = 0; i < numArray; i++) { handleTaggedArray->Set(thread, i, JSTaggedValue(array[i])); @@ -120,8 +120,8 @@ TEST_F(JSArrayIteratorTest, SetNextIndex) JSHandle handleJSObjectTaggedArray(JSArray::CreateArrayFromList(thread, handleTaggedArray)); // Call "SetNextIndex" function through "NewJSArrayIterator" function of "object_factory.cpp". - JSHandle handleJSArrayIter = factory->NewJSArrayIterator(handleJSObjectTaggedArray, - IterationKind::KEY); + JSHandle handleJSArrayIter = + factory->NewJSArrayIterator(handleJSObjectTaggedArray, IterationKind::KEY); EXPECT_EQ(handleJSArrayIter->GetNextIndex().GetNumber(), 0); int testQuantity = 100; @@ -148,7 +148,7 @@ TEST_F(JSArrayIteratorTest, SetIterationKind) ObjectFactory *factory = ecmaVMPtr->GetFactory(); uint32_t array[10] = {0, 6, 8, 99, 200, 1, static_cast(-1), static_cast(-199), 33, 100}; - int numArray = sizeof(array)/sizeof(array[0]); + int numArray = sizeof(array) / sizeof(array[0]); JSHandle handleTaggedArray(factory->NewTaggedArray(numArray)); for (int i = 0; i < numArray; i++) { handleTaggedArray->Set(thread, i, JSTaggedValue(array[i])); @@ -159,8 +159,8 @@ TEST_F(JSArrayIteratorTest, SetIterationKind) JSHandle handleJSObjectTaggedArray(JSArray::CreateArrayFromList(thread, handleTaggedArray)); // Call "SetIterationKind" function through "NewJSArrayIterator" function of "object_factory.cpp". - JSHandle handleJSArrayIter = factory->NewJSArrayIterator(handleJSObjectTaggedArray, - IterationKind::KEY); + JSHandle handleJSArrayIter = + factory->NewJSArrayIterator(handleJSObjectTaggedArray, IterationKind::KEY); EXPECT_EQ(handleJSArrayIter->GetIterationKind().GetNumber(), 0); handleJSArrayIter = factory->NewJSArrayIterator(handleJSObjectTaggedArray, IterationKind::VALUE); EXPECT_EQ(handleJSArrayIter->GetIterationKind().GetNumber(), 1); @@ -175,4 +175,4 @@ TEST_F(JSArrayIteratorTest, SetIterationKind) handleJSArrayIter->SetIterationKind(thread, handleTagVal2); EXPECT_EQ(handleJSArrayIter->GetIterationKind().GetNumber(), 2); } -} // namespace panda::ecmascript +} // namespace panda::test diff --git a/tests/runtime/common/js_dataview_test.cpp b/tests/runtime/common/js_dataview_test.cpp index fee8a84b3..b2302190f 100644 --- a/tests/runtime/common/js_dataview_test.cpp +++ b/tests/runtime/common/js_dataview_test.cpp @@ -92,8 +92,7 @@ TEST_F(JSDataViewTest, SetDataView) handleArrayBuf->SetArrayBufferByteLength(thread, JSTaggedValue(lengthDataArrayBuf)); // Call "SetDataView" function through "NewJSDataView" function of "object_factory.cpp" - JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf, offsetDataView, - lengthDataView); + JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf, offsetDataView, lengthDataView); EXPECT_TRUE(handleDataView->GetDataView().IsTrue()); // Call "SetDataView" function in this TEST_F. @@ -130,8 +129,7 @@ TEST_F(JSDataViewTest, SetViewedArrayBuffer) handleArrayBuf2->SetArrayBufferByteLength(thread, JSTaggedValue(lengthDataArrayBuf2)); // Call "SetViewedArrayBuffer" function through "NewJSDataView" function of "object_factory.cpp" - JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf1, offsetDataView, - lengthDataView); + JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf1, offsetDataView, lengthDataView); JSHandle handleTagValDataViewFrom1(thread, handleArrayBuf1.GetTaggedValue()); JSHandle handleTagValDataViewTo1(thread, handleDataView->GetViewedArrayBuffer()); EXPECT_TRUE(JSTaggedValue::Equal(thread, handleTagValDataViewFrom1, handleTagValDataViewTo1)); @@ -169,8 +167,7 @@ TEST_F(JSDataViewTest, SetByteLength) handleArrayBuf->SetArrayBufferByteLength(thread, JSTaggedValue(lengthDataArrayBuf)); // Call "SetByteLength" function through "NewJSDataView" function of "object_factory.cpp" - JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf, offsetDataView, - lengthDataView1); + JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf, offsetDataView, lengthDataView1); EXPECT_EQ(handleDataView->GetByteLength().GetNumber(), lengthDataView1); // Call "SetByteLength" function in this TEST_F. @@ -203,12 +200,11 @@ TEST_F(JSDataViewTest, SetByteOffset) handleArrayBuf->SetArrayBufferByteLength(thread, JSTaggedValue(lengthDataArrayBuf)); // Call "SetByteOffset" function through "NewJSDataView" function of "object_factory.cpp" - JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf, offsetDataView1, - lengthDataView); + JSHandle handleDataView = factory->NewJSDataView(handleArrayBuf, offsetDataView1, lengthDataView); EXPECT_EQ(handleDataView->GetByteOffset().GetNumber(), offsetDataView1); // Call "SetByteOffset" function in this TEST_F. handleDataView->SetByteOffset(thread, handleTagValOffsetDataView2); EXPECT_EQ(handleDataView->GetByteOffset().GetNumber(), offsetDataView2); } -} // namespace panda::ecmascript +} // namespace panda::test diff --git a/tests/runtime/common/js_handle_test.cpp b/tests/runtime/common/js_handle_test.cpp index 32134866e..280a88e59 100644 --- a/tests/runtime/common/js_handle_test.cpp +++ b/tests/runtime/common/js_handle_test.cpp @@ -68,8 +68,8 @@ TEST_F(JSHandleTest, NewGlobalHandle) EXPECT_TRUE(factory->NewFromString("test1")->Compare(*reinterpret_cast(globalString)) == 0); } -static void FillGlobalString(uintptr_t globalString[], int length, - EcmaGlobalStorage *global, ObjectFactory *factory, JSThread *thread) +static void FillGlobalString(uintptr_t globalString[], int length, EcmaGlobalStorage *global, ObjectFactory *factory, + JSThread *thread) { { [[maybe_unused]] EcmaHandleScope scope_nested(thread); @@ -96,15 +96,15 @@ TEST_F(JSHandleTest, NewGlobalHandle1) // check result for (int i = 0; i <= 200; i++) { std::string test = "test" + std::to_string(i); - EXPECT_TRUE( - factory->NewFromString(test.c_str())->Compare(*reinterpret_cast(globalString[i])) == 0); + EXPECT_TRUE(factory->NewFromString(test.c_str())->Compare(*reinterpret_cast(globalString[i])) == + 0); } // trigger GC thread->GetEcmaVM()->CollectGarbage(TriggerGCType::COMPRESS_FULL_GC); for (int i = 301; i < 600; i++) { std::string test = "test" + std::to_string(i); - EXPECT_TRUE( - factory->NewFromString(test.c_str())->Compare(*reinterpret_cast(globalString[i])) == 0); + EXPECT_TRUE(factory->NewFromString(test.c_str())->Compare(*reinterpret_cast(globalString[i])) == + 0); } } @@ -119,7 +119,7 @@ TEST_F(JSHandleTest, DisposeGlobalHandle) global->DisposeGlobalHandle(globalString[i]); } int count = 0; - global->IterateUsageGlobal([&count] (EcmaGlobalStorage::Node *node) { + global->IterateUsageGlobal([&count](EcmaGlobalStorage::Node *node) { JSTaggedValue value(node->GetObject()); EXPECT_TRUE(value.IsString()); count++; @@ -150,8 +150,8 @@ TEST_F(JSHandleTest, DisposeAndNewGlobalHandle) // check result for (int i = 0; i <= 300; i++) { std::string test = "test" + std::to_string(i); - EXPECT_TRUE( - factory->NewFromString(test.c_str())->Compare(*reinterpret_cast(globalString[i])) == 0); + EXPECT_TRUE(factory->NewFromString(test.c_str())->Compare(*reinterpret_cast(globalString[i])) == + 0); } } diff --git a/tests/runtime/common/js_serializer_test.cpp b/tests/runtime/common/js_serializer_test.cpp index 07499c604..26a526bfa 100644 --- a/tests/runtime/common/js_serializer_test.cpp +++ b/tests/runtime/common/js_serializer_test.cpp @@ -100,25 +100,25 @@ public: JSHandle array1 = JSObject::GetOwnPropertyKeys(thread, retObj1); int length1 = array1->GetLength(); - EXPECT_EQ(length1, 4); // 4 : test case + EXPECT_EQ(length1, 4); // 4 : test case double sum1 = 0.0; for (int i = 0; i < length1; i++) { JSHandle key(thread, array1->Get(i)); double a = JSObject::GetProperty(thread, JSHandle(retObj1), key).GetValue()->GetNumber(); sum1 += a; } - EXPECT_EQ(sum1, 10); // 10 : test case + EXPECT_EQ(sum1, 10); // 10 : test case JSHandle array2 = JSObject::GetOwnPropertyKeys(thread, retObj2); int length2 = array2->GetLength(); - EXPECT_EQ(length2, 4); // 4 : test case + EXPECT_EQ(length2, 4); // 4 : test case double sum2 = 0.0; for (int i = 0; i < length2; i++) { JSHandle key(thread, array2->Get(i)); double a = JSObject::GetProperty(thread, JSHandle(retObj2), key).GetValue()->GetNumber(); sum2 += a; } - EXPECT_EQ(sum2, 26); // 26 : test case + EXPECT_EQ(sum2, 26); // 26 : test case Destroy(); } @@ -129,7 +129,7 @@ public: JSHandle key1(factory->NewFromCanBeCompressString("x")); JSHandle key2(thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString("y")); JSHandle value1(thread, JSTaggedValue(1)); - JSHandle value2(thread, JSTaggedValue(2)); // 2 : test case + JSHandle value2(thread, JSTaggedValue(2)); // 2 : test case JSDeserializer deserializer(thread, data.first, data.second); JSHandle objValue = deserializer.DeserializeJSTaggedValue(); @@ -161,8 +161,8 @@ public: { Init(); ObjectFactory *factory = ecmaVm->GetFactory(); - JSHandle value1(thread, JSTaggedValue(7)); // 7 : test case - JSHandle value2(thread, JSTaggedValue(9)); // 9 : test case + JSHandle value1(thread, JSTaggedValue(7)); // 7 : test case + JSHandle value2(thread, JSTaggedValue(9)); // 9 : test case JSHandle value3(factory->NewFromCanBeCompressString("x")); JSHandle value4(factory->NewFromCanBeCompressString("y")); @@ -172,14 +172,14 @@ public: JSHandle retSet = JSHandle::Cast(setValue); JSHandle array = JSObject::GetOwnPropertyKeys(thread, JSHandle::Cast(retSet)); int propertyLength = array->GetLength(); - EXPECT_EQ(propertyLength, 2); // 2 : test case + EXPECT_EQ(propertyLength, 2); // 2 : test case int sum = 0; for (int i = 0; i < propertyLength; i++) { JSHandle key(thread, array->Get(i)); double a = JSObject::GetProperty(thread, JSHandle(retSet), key).GetValue()->GetNumber(); sum += a; } - EXPECT_EQ(sum, 16); // 16 : test case + EXPECT_EQ(sum, 16); // 16 : test case EXPECT_EQ(retSet->GetSize(), 4); // 4 : test case EXPECT_TRUE(retSet->Has(value1.GetTaggedValue())); @@ -247,10 +247,13 @@ public: void EcmaStringTest2(std::pair data) { Init(); - const char *rawStr = "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"\ - "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"\ - "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"\ - "ssssss"; + const char *rawStr = + "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" + "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" + "s" + "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" + "s" + "ssssss"; JSHandle ecmaString = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(rawStr); JSDeserializer deserializer(thread, data.first, data.second); @@ -334,8 +337,8 @@ public: Destroy(); } - void JSArrayBufferTest(std::pair data, - const JSHandle &originArrayBuffer, int32_t byteLength, const char *msg) + void JSArrayBufferTest(std::pair data, const JSHandle &originArrayBuffer, + int32_t byteLength, const char *msg) { Init(); JSDeserializer deserializer(thread, data.first, data.second); @@ -345,7 +348,7 @@ public: JSHandle resJSArrayBuffer = JSHandle::Cast(res); JSTaggedValue resTaggedLength = resJSArrayBuffer->GetArrayBufferByteLength(); int32_t resByteLength = static_cast(resTaggedLength.GetInt()); - EXPECT_TRUE(resByteLength == byteLength) << "Not Same ByteLength"; // 10 : test case + EXPECT_TRUE(resByteLength == byteLength) << "Not Same ByteLength"; // 10 : test case JSHandle bufferData(thread, originArrayBuffer->GetArrayBufferData()); auto np = JSHandle::Cast(bufferData); @@ -699,10 +702,11 @@ TEST_F(JSSerializerTest, SerializeEcmaString1) TEST_F(JSSerializerTest, SerializeEcmaString2) { - const char *rawStr = "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"\ - "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"\ - "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"\ - "ssssss"; + const char *rawStr = + "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" + "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" + "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss" + "ssssss"; JSHandle ecmaString = thread->GetEcmaVM()->GetFactory()->NewFromCanBeCompressString(rawStr); JSSerializer *serializer = new JSSerializer(thread); bool success = serializer->SerializeJSTaggedValue(JSHandle(ecmaString)); @@ -837,7 +841,7 @@ TEST_F(JSSerializerTest, SerializeJSArrayBufferShared) { std::string msg = "hello world"; int msgBufferLen = msg.length() + 1; - char* msgBuffer = new char[msgBufferLen] { 0 }; + char *msgBuffer = new char[msgBufferLen] {0}; if (memcpy_s(msgBuffer, msgBufferLen, msg.c_str(), msgBufferLen) != EOK) { delete[] msgBuffer; EXPECT_TRUE(false) << " memcpy error"; @@ -860,7 +864,7 @@ TEST_F(JSSerializerTest, SerializeJSArrayBufferShared2) { std::string msg = "hello world"; int msgBufferLen = msg.length() + 1; - char* msgBuffer = new char[msgBufferLen] { 0 }; + char *msgBuffer = new char[msgBufferLen] {0}; if (memcpy_s(msgBuffer, msgBufferLen, msg.c_str(), msgBufferLen) != EOK) { delete[] msgBuffer; EXPECT_TRUE(false) << " memcpy error"; @@ -875,8 +879,8 @@ TEST_F(JSSerializerTest, SerializeJSArrayBufferShared2) std::pair data = serializer->ReleaseBuffer(); JSDeserializerTest jsDeserializerTest; std::string changeStr = "world hello"; - std::thread t1(&JSDeserializerTest::JSArrayBufferTest, - jsDeserializerTest, data, jsArrayBuffer, 12, changeStr.c_str()); + std::thread t1(&JSDeserializerTest::JSArrayBufferTest, jsDeserializerTest, data, jsArrayBuffer, 12, + changeStr.c_str()); t1.join(); EXPECT_TRUE(strcmp(msgBuffer, "world hello") == 0) << "Serialize JSArrayBuffer fail"; delete serializer; diff --git a/tests/runtime/common/mem_controller_test.cpp b/tests/runtime/common/mem_controller_test.cpp index 52c768df4..f4201425e 100644 --- a/tests/runtime/common/mem_controller_test.cpp +++ b/tests/runtime/common/mem_controller_test.cpp @@ -68,16 +68,16 @@ TEST_F(MemControllerTest, AllocationVerify) for (int i = 0; i < 1024; i++) { // old space object - [[maybe_unused]] auto oldArray = objectFactory->NewTaggedArray(128, JSTaggedValue::Undefined(), - MemSpaceType::OLD_SPACE); + [[maybe_unused]] auto oldArray = + objectFactory->NewTaggedArray(128, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE); } sleep(5); heap->CollectGarbage(TriggerGCType::COMPRESS_FULL_GC); double mutatorSpeed1 = memController->GetCurrentOldSpaceAllocationThroughtputPerMS(0); for (int i = 0; i < 1024; i++) { // old space object - [[maybe_unused]] auto oldArray = objectFactory->NewTaggedArray(128, JSTaggedValue::Undefined(), - MemSpaceType::OLD_SPACE); + [[maybe_unused]] auto oldArray = + objectFactory->NewTaggedArray(128, JSTaggedValue::Undefined(), MemSpaceType::OLD_SPACE); } sleep(10); @@ -112,8 +112,8 @@ TEST_F(MemControllerTest, VerifyMutatorSpeed) static constexpr size_t SIZE = 1024 * 1024; auto hugeArray = objectFactory->NewTaggedArray(SIZE); - ASSERT_TRUE(heap->GetNewSpace()->GetAllocatedSizeSinceGC() - == newArray->ComputeSize(JSTaggedValue::TaggedTypeSize(), 2)); + ASSERT_TRUE(heap->GetNewSpace()->GetAllocatedSizeSinceGC() == + newArray->ComputeSize(JSTaggedValue::TaggedTypeSize(), 2)); heap->CollectGarbage(TriggerGCType::SEMI_GC); @@ -124,10 +124,10 @@ TEST_F(MemControllerTest, VerifyMutatorSpeed) size_t hugeObjectAllocSizeInLastGC = memController->GetHugeObjectAllocSizeSinceGC(); ASSERT_TRUE(allocDurationAfter - allocDurationBefore > 1000); - ASSERT_TRUE(oldSpaceAllocatedSizeAfter - oldSpaceAllocatedSizeBefore - == oldArray->ComputeSize(JSTaggedValue::TaggedTypeSize(), 2)); - ASSERT_TRUE(nonMovableSpaceAllocatedSizeAfter - nonMovableSpaceAllocatedSizeBefore - == nonMovableArray->ComputeSize(JSTaggedValue::TaggedTypeSize(), 2)); + ASSERT_TRUE(oldSpaceAllocatedSizeAfter - oldSpaceAllocatedSizeBefore == + oldArray->ComputeSize(JSTaggedValue::TaggedTypeSize(), 2)); + ASSERT_TRUE(nonMovableSpaceAllocatedSizeAfter - nonMovableSpaceAllocatedSizeBefore == + nonMovableArray->ComputeSize(JSTaggedValue::TaggedTypeSize(), 2)); // The allocated size of huge object must be larger than the object size. ASSERT_TRUE(hugeObjectAllocSizeInLastGC > hugeArray->ComputeSize(JSTaggedValue::TaggedTypeSize(), SIZE)); #endif diff --git a/tests/runtime/common/object_factory_test.cpp b/tests/runtime/common/object_factory_test.cpp index febb0ddd0..b23562aee 100644 --- a/tests/runtime/common/object_factory_test.cpp +++ b/tests/runtime/common/object_factory_test.cpp @@ -64,7 +64,7 @@ JSHandle GetGlobal(JSThread *thread) return thread->GetEcmaVM()->GetGlobalEnv(); } -TEST_F(ObjectFactoryTest, DISABLED_NewJSObjectByConstructor) // TODO(vpukhov) +TEST_F(ObjectFactoryTest, DISABLED_NewJSObjectByConstructor) // TODO(vpukhov) { thread->GetEcmaVM()->SetEnableForceGC(false); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); diff --git a/tests/runtime/common/symbol_table_test.cpp b/tests/runtime/common/symbol_table_test.cpp index 5f9776302..a5505ad5a 100644 --- a/tests/runtime/common/symbol_table_test.cpp +++ b/tests/runtime/common/symbol_table_test.cpp @@ -116,14 +116,14 @@ TEST_F(SymbolTableTest, Hash_Utf8) bool flag = EcmaString::GetCompressedStringsEnabled(); EXPECT_EQ(flag, true); - uint8_t utf8ArrayName1[4] = {1, 2, 3}; // The last element is "\0" + uint8_t utf8ArrayName1[4] = {1, 2, 3}; // The last element is "\0" uint32_t utf8ArrayNameLen1 = sizeof(utf8ArrayName1) - 1; - JSHandle nameStringUtf8Obj1 =factory->NewFromUtf8(utf8ArrayName1, utf8ArrayNameLen1); - EXPECT_EQ(SymbolTable::Hash(nameStringUtf8Obj1.GetTaggedValue()), 1026); // 1026 = (1 << 5 - 1 + 2) << 5 - 2 + 3 + JSHandle nameStringUtf8Obj1 = factory->NewFromUtf8(utf8ArrayName1, utf8ArrayNameLen1); + EXPECT_EQ(SymbolTable::Hash(nameStringUtf8Obj1.GetTaggedValue()), 1026); // 1026 = (1 << 5 - 1 + 2) << 5 - 2 + 3 uint8_t utf8ArrayName2[] = "key"; uint32_t utf8ArrayNameLen2 = sizeof(utf8ArrayName2) - 1; - JSHandle nameStringUtf8Obj2 =factory->NewFromUtf8(utf8ArrayName2, utf8ArrayNameLen2); + JSHandle nameStringUtf8Obj2 = factory->NewFromUtf8(utf8ArrayName2, utf8ArrayNameLen2); EXPECT_EQ(SymbolTable::Hash(nameStringUtf8Obj2.GetTaggedValue()), 106079); } @@ -141,13 +141,13 @@ TEST_F(SymbolTableTest, Hash_Utf16) uint16_t utf16ArrayName1[] = {1, 2, 3}; uint32_t utf16ArrayNameLen1 = sizeof(utf16ArrayName1) / sizeof(utf16ArrayName1[0]); - JSHandle nameStringUtf16Obj1 =factory->NewFromUtf16(utf16ArrayName1, utf16ArrayNameLen1); - EXPECT_EQ(SymbolTable::Hash(nameStringUtf16Obj1.GetTaggedValue()), 1026); // 1026 = (1 << 5 - 1 + 2) << 5 - 2 + 3 + JSHandle nameStringUtf16Obj1 = factory->NewFromUtf16(utf16ArrayName1, utf16ArrayNameLen1); + EXPECT_EQ(SymbolTable::Hash(nameStringUtf16Obj1.GetTaggedValue()), 1026); // 1026 = (1 << 5 - 1 + 2) << 5 - 2 + 3 uint16_t utf16ArrayName2[] = {0, 1, 2}; uint32_t utf16ArrayNameLen2 = sizeof(utf16ArrayName2) / sizeof(utf16ArrayName2[0]); - JSHandle nameStringUtf16Obj2 =factory->NewFromUtf16(utf16ArrayName2, utf16ArrayNameLen2); - EXPECT_EQ(SymbolTable::Hash(nameStringUtf16Obj2.GetTaggedValue()), 33); // 33 = (0 << 5 - 0 + 1) << 5 - 1 + 2 + JSHandle nameStringUtf16Obj2 = factory->NewFromUtf16(utf16ArrayName2, utf16ArrayNameLen2); + EXPECT_EQ(SymbolTable::Hash(nameStringUtf16Obj2.GetTaggedValue()), 33); // 33 = (0 << 5 - 0 + 1) << 5 - 1 + 2 } /* @@ -267,4 +267,4 @@ TEST_F(SymbolTableTest, FindSymbol) JSTaggedValue resultValue4 = symbolTable->FindSymbol(thread, handleSymbol.GetTaggedValue()); EXPECT_EQ(JSTaggedValue::SameValue(resultValue4, JSTaggedValue::Undefined()), true); } -} // namespace panda::ecmascript +} // namespace panda::test diff --git a/tests/runtime/common/test_helper.h b/tests/runtime/common/test_helper.h index 294c0f66e..eb039f0c7 100644 --- a/tests/runtime/common/test_helper.h +++ b/tests/runtime/common/test_helper.h @@ -67,8 +67,7 @@ public: } } - static inline void DestroyEcmaVMWithScope(PandaVM *instance, EcmaHandleScope *scope, - bool exit_managed_code = true) + static inline void DestroyEcmaVMWithScope(PandaVM *instance, EcmaHandleScope *scope, bool exit_managed_code = true) { auto thread = EcmaVM::Cast(instance)->GetAssociatedJSThread(); if (exit_managed_code) { diff --git a/tests/runtime/common/visitor_compatibility_tests.cpp b/tests/runtime/common/visitor_compatibility_tests.cpp index 956a0e226..714b23d0e 100644 --- a/tests/runtime/common/visitor_compatibility_tests.cpp +++ b/tests/runtime/common/visitor_compatibility_tests.cpp @@ -199,10 +199,10 @@ public: return Cmp(SwitchCaseVisitor(object, klass), UnifiedVisitor(object, klass)); } - PandaVM *instance{nullptr}; - EcmaVM *ecma_vm{nullptr}; - EcmaHandleScope *scope{nullptr}; - ObjectFactory *factory{nullptr}; + PandaVM *instance {nullptr}; + EcmaVM *ecma_vm {nullptr}; + EcmaHandleScope *scope {nullptr}; + ObjectFactory *factory {nullptr}; JSThread *thread; }; @@ -233,8 +233,7 @@ TEST_F(VisitorCompatibilityTest, JSGlobalObject) auto global_object = env->GetJSGlobalObject(); auto klass = JSObject::Cast(global_object.GetTaggedValue())->GetJSHClass(); ASSERT_EQ(klass->GetObjectType(), JSType::JS_GLOBAL_OBJECT); - ASSERT_TRUE(WrappedCmp(JSObject::Cast(global_object.GetTaggedValue()), - klass)); + ASSERT_TRUE(WrappedCmp(JSObject::Cast(global_object.GetTaggedValue()), klass)); } TEST_F(VisitorCompatibilityTest, JSTaggedArray) diff --git a/tests/runtime/hprof/heap_tracker_test.cpp b/tests/runtime/hprof/heap_tracker_test.cpp index 46bb7319c..14badabe5 100644 --- a/tests/runtime/hprof/heap_tracker_test.cpp +++ b/tests/runtime/hprof/heap_tracker_test.cpp @@ -56,7 +56,7 @@ public: JSThread *thread {nullptr}; }; -TEST_F(HeapTrackerTest, DISABLED_HeapTracker) // issue #5368 +TEST_F(HeapTrackerTest, DISABLED_HeapTracker) // issue #5368 { [[maybe_unused]] EcmaHandleScope handleScope(thread); HeapProfilerInterface *heapProfile = HeapProfilerInterface::CreateHeapProfiler(thread); diff --git a/tests/runtime/ic/ic_binaryop_test.cpp b/tests/runtime/ic/ic_binaryop_test.cpp index 59346a839..728905c9e 100644 --- a/tests/runtime/ic/ic_binaryop_test.cpp +++ b/tests/runtime/ic/ic_binaryop_test.cpp @@ -69,62 +69,61 @@ TEST_F(ICBinaryOPTest, AddWithTSType) JSHandle arg2(thread, arg2Value); JSHandle arg3(thread, arg3Value); - JSTaggedValue resInSlowPath1 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(), - arg2.GetTaggedValue()); + JSTaggedValue resInSlowPath1 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(), arg2.GetTaggedValue()); JSHandle slowHandle1(thread, resInSlowPath1); JSTaggedValue resInICPath1 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg2.GetTaggedValue(), JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(slowHandle1.GetTaggedValue(), resInICPath1); - JSTaggedValue resInSlowPath2 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(), - arg3.GetTaggedValue()); + JSTaggedValue resInSlowPath2 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(), arg3.GetTaggedValue()); JSHandle slowHandle2(thread, resInSlowPath2); JSTaggedValue resInICPath2 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), arg3.GetTaggedValue(), JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(slowHandle2.GetTaggedValue(), resInICPath2); - JSTaggedValue resInSlowPath3 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, Str1.GetTaggedValue(), - Str2.GetTaggedValue()); + JSTaggedValue resInSlowPath3 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, Str1.GetTaggedValue(), Str2.GetTaggedValue()); JSHandle slowHandle3(thread, reinterpret_cast(resInSlowPath3.GetRawData())); JSTaggedValue resInICPath3 = ICBinaryOP::AddWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), Str2.GetTaggedValue(), JSTaggedValue(static_cast(BinaryType::STRING))); ASSERT_TRUE(resInICPath3.IsString()); EXPECT_EQ(slowHandle3->Compare(reinterpret_cast(resInICPath3.GetRawData())), 0); - JSTaggedValue resInSlowPath4 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, JSTaggedValue::Undefined(), - arg2.GetTaggedValue()); + JSTaggedValue resInSlowPath4 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, JSTaggedValue::Undefined(), arg2.GetTaggedValue()); JSHandle slowHandle4(thread, resInSlowPath4); - JSTaggedValue resInICPath4 = ICBinaryOP::AddWithTSType(thread, ecmaVm, JSTaggedValue::Undefined(), - arg2.GetTaggedValue(), - JSTaggedValue(static_cast(BinaryType::NUMBER_GEN))); + JSTaggedValue resInICPath4 = + ICBinaryOP::AddWithTSType(thread, ecmaVm, JSTaggedValue::Undefined(), arg2.GetTaggedValue(), + JSTaggedValue(static_cast(BinaryType::NUMBER_GEN))); EXPECT_EQ(slowHandle4.GetTaggedValue(), resInICPath4); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg3.GetTaggedValue(), - Str1.GetTaggedValue()); + JSTaggedValue resInSlowPath5 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg3.GetTaggedValue(), Str1.GetTaggedValue()); JSHandle slowHandle5(thread, reinterpret_cast(resInSlowPath5.GetRawData())); - JSTaggedValue resInICPath5 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg3.GetTaggedValue(), - Str1.GetTaggedValue(), + JSTaggedValue resInICPath5 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg3.GetTaggedValue(), Str1.GetTaggedValue(), JSTaggedValue(static_cast(BinaryType::STRING_GEN))); ASSERT_TRUE(resInICPath5.IsString()); EXPECT_EQ(slowHandle5->Compare(reinterpret_cast(resInICPath5.GetRawData())), 0); - JSTaggedValue resInSlowPath6 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, Str1.GetTaggedValue(), - JSTaggedValue::Null()); + JSTaggedValue resInSlowPath6 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, Str1.GetTaggedValue(), JSTaggedValue::Null()); JSHandle slowHandle6(thread, reinterpret_cast(resInSlowPath6.GetRawData())); JSTaggedValue resInICPath6 = ICBinaryOP::AddWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), JSTaggedValue::Null(), JSTaggedValue(static_cast(BinaryType::STRING_GEN))); ASSERT_TRUE(resInICPath6.IsString()); EXPECT_EQ(slowHandle6->Compare(reinterpret_cast(resInICPath6.GetRawData())), 0); - JSTaggedValue resInSlowPath7 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(), - JSTaggedValue::True()); + JSTaggedValue resInSlowPath7 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg1.GetTaggedValue(), JSTaggedValue::True()); JSHandle slowHandle7(thread, resInSlowPath7); JSTaggedValue resInICPath7 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), JSTaggedValue::True(), JSTaggedValue(static_cast(BinaryType::NUMBER_GEN))); EXPECT_EQ(slowHandle7.GetTaggedValue(), resInICPath7); - JSTaggedValue resInSlowPath8 = SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg4.GetTaggedValue(), - JSTaggedValue::Null()); + JSTaggedValue resInSlowPath8 = + SlowRuntimeStub::Add2Dyn(thread, ecmaVm, arg4.GetTaggedValue(), JSTaggedValue::Null()); JSHandle slowHandle8(thread, reinterpret_cast(resInSlowPath8.GetRawData())); JSTaggedValue resInICPath8 = ICBinaryOP::AddWithTSType(thread, ecmaVm, arg4.GetTaggedValue(), JSTaggedValue::Null(), JSTaggedValue(static_cast(BinaryType::GENERIC))); @@ -135,7 +134,7 @@ TEST_F(ICBinaryOPTest, AddWithTSType) TEST_F(ICBinaryOPTest, SubWithTSType) { JSTaggedValue arg1Value(static_cast(-2)); - JSTaggedValue arg2Value(static_cast(INT32_MAX-1)); + JSTaggedValue arg2Value(static_cast(INT32_MAX - 1)); JSTaggedValue arg3Value(static_cast(9.5561)); JSHandle arg1(thread, arg1Value); JSHandle arg2(thread, arg2Value); @@ -186,7 +185,6 @@ TEST_F(ICBinaryOPTest, MulWithTSType) JSTaggedValue resInICPath3 = ICBinaryOP::MulWithTSType(thread, ecmaVm, arg1.GetTaggedValue(), JSTaggedValue::True(), JSTaggedValue(static_cast(BinaryType::GENERIC))); EXPECT_EQ(slowHandle3.GetTaggedValue(), resInICPath3); - }; TEST_F(ICBinaryOPTest, DivWithTSType) @@ -226,9 +224,9 @@ TEST_F(ICBinaryOPTest, DivWithTSType) JSTaggedValue resInSlowPath5 = SlowRuntimeStub::Div2Dyn(thread, arg4.GetTaggedValue(), JSTaggedValue::False()); JSHandle slowHandle5(thread, resInSlowPath5); - JSTaggedValue resInICPath5 = ICBinaryOP::DivWithTSType(thread, ecmaVm, arg4.GetTaggedValue(), - JSTaggedValue::False(), - JSTaggedValue(static_cast(BinaryType::GENERIC))); + JSTaggedValue resInICPath5 = + ICBinaryOP::DivWithTSType(thread, ecmaVm, arg4.GetTaggedValue(), JSTaggedValue::False(), + JSTaggedValue(static_cast(BinaryType::GENERIC))); EXPECT_EQ(slowHandle5.GetTaggedValue(), resInICPath5); }; @@ -261,19 +259,17 @@ TEST_F(ICBinaryOPTest, ModWithTSType) JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(slowHandle3.GetTaggedValue(), resInICPath3); - JSTaggedValue resInSlowPath4 = SlowRuntimeStub::Mod2Dyn(thread, arg2.GetTaggedValue(), JSTaggedValue::True()); JSHandle slowHandle4(thread, resInSlowPath4); JSTaggedValue resInICPath4 = ICBinaryOP::ModWithTSType(thread, ecmaVm, arg2.GetTaggedValue(), JSTaggedValue::True(), JSTaggedValue(static_cast(BinaryType::GENERIC))); EXPECT_EQ(slowHandle4.GetTaggedValue(), resInICPath4); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::Mod2Dyn(thread, arg4.GetTaggedValue(), JSTaggedValue::False()); JSHandle slowHandle5(thread, resInSlowPath5); - JSTaggedValue resInICPath5 = ICBinaryOP::ModWithTSType(thread, ecmaVm, arg4.GetTaggedValue(), - JSTaggedValue::False(), - JSTaggedValue(static_cast(BinaryType::GENERIC))); + JSTaggedValue resInICPath5 = + ICBinaryOP::ModWithTSType(thread, ecmaVm, arg4.GetTaggedValue(), JSTaggedValue::False(), + JSTaggedValue(static_cast(BinaryType::GENERIC))); EXPECT_EQ(slowHandle5.GetTaggedValue(), resInICPath5); }; @@ -285,8 +281,8 @@ TEST_F(ICBinaryOPTest, ShlWithTSType) JSTaggedValue arg1(static_cast(286)); JSTaggedValue arg3(static_cast(5)); - JSTaggedValue resInICPath1 = ICBinaryOP::ShlWithTSType(thread, ecmaVm, arg1, arg3, - JSTaggedValue(static_cast(BinaryType::NUMBER))); + JSTaggedValue resInICPath1 = + ICBinaryOP::ShlWithTSType(thread, ecmaVm, arg1, arg3, JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(JSTaggedValue(9152), resInICPath1); JSTaggedValue resInICPath2 = ICBinaryOP::ShlWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3, @@ -302,8 +298,8 @@ TEST_F(ICBinaryOPTest, ShrWithTSType) JSTaggedValue arg1(static_cast(286)); JSTaggedValue arg3(static_cast(5)); - JSTaggedValue resInICPath1 = ICBinaryOP::ShrWithTSType(thread, ecmaVm, arg1, arg3, - JSTaggedValue(static_cast(BinaryType::NUMBER))); + JSTaggedValue resInICPath1 = + ICBinaryOP::ShrWithTSType(thread, ecmaVm, arg1, arg3, JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(JSTaggedValue(8), resInICPath1); JSTaggedValue resInICPath2 = ICBinaryOP::ShrWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3, @@ -320,18 +316,17 @@ TEST_F(ICBinaryOPTest, AshrWithTSType) JSTaggedValue arg2(static_cast(-286)); JSTaggedValue arg3(static_cast(5)); - JSTaggedValue resInICPath1 = ICBinaryOP::AshrWithTSType(thread, ecmaVm, arg1, arg3, - JSTaggedValue(static_cast(BinaryType::NUMBER))); + JSTaggedValue resInICPath1 = + ICBinaryOP::AshrWithTSType(thread, ecmaVm, arg1, arg3, JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(JSTaggedValue(8), resInICPath1); - JSTaggedValue resInICPath3 = ICBinaryOP::AshrWithTSType(thread, ecmaVm, arg2, arg3, - JSTaggedValue(static_cast(BinaryType::NUMBER))); + JSTaggedValue resInICPath3 = + ICBinaryOP::AshrWithTSType(thread, ecmaVm, arg2, arg3, JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(JSTaggedValue(134217719), resInICPath3); JSTaggedValue resInICPath2 = ICBinaryOP::AshrWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3, JSTaggedValue(static_cast(BinaryType::GENERIC))); EXPECT_EQ(JSTaggedValue(7), resInICPath2); - }; TEST_F(ICBinaryOPTest, AndWithTSType) { @@ -341,8 +336,8 @@ TEST_F(ICBinaryOPTest, AndWithTSType) JSTaggedValue arg1(static_cast(286)); JSTaggedValue arg3(static_cast(541)); - JSTaggedValue resInICPath1 = ICBinaryOP::AndWithTSType(thread, ecmaVm, arg1, arg3, - JSTaggedValue(static_cast(BinaryType::NUMBER))); + JSTaggedValue resInICPath1 = + ICBinaryOP::AndWithTSType(thread, ecmaVm, arg1, arg3, JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(JSTaggedValue(28), resInICPath1); JSTaggedValue resInICPath2 = ICBinaryOP::AndWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3, @@ -357,8 +352,8 @@ TEST_F(ICBinaryOPTest, OrWithTSType) JSTaggedValue arg1(static_cast(286)); JSTaggedValue arg3(static_cast(523)); - JSTaggedValue resInICPath1 = ICBinaryOP::OrWithTSType(thread, ecmaVm, arg1, arg3, - JSTaggedValue(static_cast(BinaryType::NUMBER))); + JSTaggedValue resInICPath1 = + ICBinaryOP::OrWithTSType(thread, ecmaVm, arg1, arg3, JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(JSTaggedValue(799), resInICPath1); JSTaggedValue resInICPath2 = ICBinaryOP::OrWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3, @@ -373,8 +368,8 @@ TEST_F(ICBinaryOPTest, XorWithTSType) JSTaggedValue arg1(static_cast(286)); JSTaggedValue arg3(static_cast(523)); - JSTaggedValue resInICPath1 = ICBinaryOP::XorWithTSType(thread, ecmaVm, arg1, arg3, - JSTaggedValue(static_cast(BinaryType::NUMBER))); + JSTaggedValue resInICPath1 = + ICBinaryOP::XorWithTSType(thread, ecmaVm, arg1, arg3, JSTaggedValue(static_cast(BinaryType::NUMBER))); EXPECT_EQ(JSTaggedValue(789), resInICPath1); JSTaggedValue resInICPath2 = ICBinaryOP::XorWithTSType(thread, ecmaVm, Str1.GetTaggedValue(), arg3, diff --git a/tests/runtime/ic/ic_compareop_test.cpp b/tests/runtime/ic/ic_compareop_test.cpp index 318bc07ae..31be6295b 100644 --- a/tests/runtime/ic/ic_compareop_test.cpp +++ b/tests/runtime/ic/ic_compareop_test.cpp @@ -86,30 +86,30 @@ TEST_F(IcCompareOPTest, EqualWithIC) JSTaggedValue booleanObj = builtins::BuiltinsBoolean::BooleanConstructor(ecmaRuntimeCallInfo.get()); JSHandle booleanObjHandle(thread, booleanObj); - JSTaggedValue resInSlowPath1 = SlowRuntimeStub::EqDyn(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath1 = + SlowRuntimeStub::EqDyn(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue()); JSTaggedValue resInSlowPath2 = SlowRuntimeStub::EqDyn(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue()); JSTaggedValue resInSlowPath3 = SlowRuntimeStub::EqDyn(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue()); JSTaggedValue resInSlowPath4 = SlowRuntimeStub::EqDyn(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::EqDyn(thread, booleanObjHandle.GetTaggedValue(), - arg4Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath5 = + SlowRuntimeStub::EqDyn(thread, booleanObjHandle.GetTaggedValue(), arg4Handle.GetTaggedValue()); JSTaggedValue resInSlowPath9 = SlowRuntimeStub::EqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null()); JSTaggedValue resInSlowPath10 = SlowRuntimeStub::EqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::True()); JSTaggedValue resInICPath1 = CompareOp::EqualWithIC(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); - JSTaggedValue resInICPath2 = CompareOp::EqualWithIC(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue(), CompareOpType::STRING_NUMBER); - JSTaggedValue resInICPath3 = CompareOp::EqualWithIC(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath4 = CompareOp::EqualWithIC(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath2 = CompareOp::EqualWithIC(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue(), + CompareOpType::STRING_NUMBER); + JSTaggedValue resInICPath3 = CompareOp::EqualWithIC(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath4 = CompareOp::EqualWithIC(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); JSTaggedValue resInICPath5 = CompareOp::EqualWithIC(thread, booleanObjHandle.GetTaggedValue(), arg4Handle.GetTaggedValue(), CompareOpType::OBJ_BOOLEAN); - JSTaggedValue resInICPath9 = CompareOp::EqualWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null(), CompareOpType::UNDEFINED_NULL); - JSTaggedValue resInICPath10 = CompareOp::EqualWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True(), CompareOpType::OTHER); + JSTaggedValue resInICPath9 = CompareOp::EqualWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null(), + CompareOpType::UNDEFINED_NULL); + JSTaggedValue resInICPath10 = + CompareOp::EqualWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::True(), CompareOpType::OTHER); EXPECT_EQ(resInSlowPath1, resInICPath1); EXPECT_EQ(resInSlowPath2, resInICPath2); @@ -145,37 +145,34 @@ TEST_F(IcCompareOPTest, NotEqualWithIC) JSTaggedValue booleanObj = builtins::BuiltinsBoolean::BooleanConstructor(ecmaRuntimeCallInfo.get()); JSHandle booleanObjHandle(thread, booleanObj); - JSTaggedValue resInSlowPath1 = SlowRuntimeStub::NotEqDyn(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath2 = SlowRuntimeStub::NotEqDyn(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath3 = SlowRuntimeStub::NotEqDyn(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath4 = SlowRuntimeStub::NotEqDyn(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::NotEqDyn(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue()); - JSTaggedValue resInSlowPath9 = SlowRuntimeStub::NotEqDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null()); - JSTaggedValue resInSlowPath10 = SlowRuntimeStub::NotEqDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True()); + JSTaggedValue resInSlowPath1 = + SlowRuntimeStub::NotEqDyn(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath2 = + SlowRuntimeStub::NotEqDyn(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath3 = + SlowRuntimeStub::NotEqDyn(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath4 = + SlowRuntimeStub::NotEqDyn(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath5 = + SlowRuntimeStub::NotEqDyn(thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue()); + JSTaggedValue resInSlowPath9 = SlowRuntimeStub::NotEqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null()); + JSTaggedValue resInSlowPath10 = + SlowRuntimeStub::NotEqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::True()); JSTaggedValue resInICPath1 = CompareOp::NotEqualWithIC(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue(), - CompareOpType::NUMBER_NUMBER); - JSTaggedValue resInICPath2 = CompareOp::NotEqualWithIC(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue(), CompareOpType::STRING_NUMBER); - JSTaggedValue resInICPath3 = CompareOp::NotEqualWithIC(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath4 = CompareOp::NotEqualWithIC(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath5 = CompareOp::NotEqualWithIC(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue(), - CompareOpType::NUMBER_OBJ); - JSTaggedValue resInICPath9 = CompareOp::NotEqualWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null(), CompareOpType::UNDEFINED_NULL); - JSTaggedValue resInICPath10 = CompareOp::NotEqualWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True(), CompareOpType::OTHER); + arg2Handle.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); + JSTaggedValue resInICPath2 = CompareOp::NotEqualWithIC(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue(), + CompareOpType::STRING_NUMBER); + JSTaggedValue resInICPath3 = CompareOp::NotEqualWithIC(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath4 = CompareOp::NotEqualWithIC(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath5 = CompareOp::NotEqualWithIC( + thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue(), CompareOpType::NUMBER_OBJ); + JSTaggedValue resInICPath9 = CompareOp::NotEqualWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null(), + CompareOpType::UNDEFINED_NULL); + JSTaggedValue resInICPath10 = + CompareOp::NotEqualWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::True(), CompareOpType::OTHER); EXPECT_EQ(resInSlowPath1, resInICPath1); EXPECT_EQ(resInSlowPath2, resInICPath2); @@ -186,7 +183,6 @@ TEST_F(IcCompareOPTest, NotEqualWithIC) EXPECT_EQ(resInSlowPath10, resInICPath10); }; - TEST_F(IcCompareOPTest, LessDynWithIC) { ObjectFactory *factory = ecmaVm->GetFactory(); @@ -213,36 +209,30 @@ TEST_F(IcCompareOPTest, LessDynWithIC) JSTaggedValue booleanObj = builtins::BuiltinsBoolean::BooleanConstructor(ecmaRuntimeCallInfo.get()); JSHandle booleanObjHandle(thread, booleanObj); - JSTaggedValue resInSlowPath1 = SlowRuntimeStub::LessDyn(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath2 = SlowRuntimeStub::LessDyn(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath3 = SlowRuntimeStub::LessDyn(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath4 = SlowRuntimeStub::LessDyn(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::LessDyn(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue()); - JSTaggedValue resInSlowPath9 = SlowRuntimeStub::LessDyn(thread, - JSTaggedValue::Undefined(), JSTaggedValue::Null()); - JSTaggedValue resInSlowPath10 = SlowRuntimeStub::LessDyn(thread, - JSTaggedValue::Undefined(), JSTaggedValue::True()); - - JSTaggedValue resInICPath1 = CompareOp::LessDynWithIC(thread, arg1Handle.GetTaggedValue(), + JSTaggedValue resInSlowPath1 = + SlowRuntimeStub::LessDyn(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath2 = SlowRuntimeStub::LessDyn(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath3 = SlowRuntimeStub::LessDyn(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath4 = SlowRuntimeStub::LessDyn(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath5 = + SlowRuntimeStub::LessDyn(thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue()); + JSTaggedValue resInSlowPath9 = SlowRuntimeStub::LessDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null()); + JSTaggedValue resInSlowPath10 = SlowRuntimeStub::LessDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::True()); + + JSTaggedValue resInICPath1 = CompareOp::LessDynWithIC(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); - JSTaggedValue resInICPath2 = CompareOp::LessDynWithIC(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue(), CompareOpType::STRING_NUMBER); - JSTaggedValue resInICPath3 = CompareOp::LessDynWithIC(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath4 = CompareOp::LessDynWithIC(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath5 = CompareOp::LessDynWithIC(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue(), - CompareOpType::NUMBER_OBJ); - JSTaggedValue resInICPath9 = CompareOp::LessDynWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null(), CompareOpType::UNDEFINED_NULL); - JSTaggedValue resInICPath10 = CompareOp::LessDynWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True(), CompareOpType::OTHER); + JSTaggedValue resInICPath2 = CompareOp::LessDynWithIC(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue(), + CompareOpType::STRING_NUMBER); + JSTaggedValue resInICPath3 = CompareOp::LessDynWithIC(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath4 = CompareOp::LessDynWithIC(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue(), + CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath5 = CompareOp::LessDynWithIC(thread, arg1Handle.GetTaggedValue(), + booleanObjHandle.GetTaggedValue(), CompareOpType::NUMBER_OBJ); + JSTaggedValue resInICPath9 = CompareOp::LessDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null(), + CompareOpType::UNDEFINED_NULL); + JSTaggedValue resInICPath10 = + CompareOp::LessDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::True(), CompareOpType::OTHER); EXPECT_EQ(resInSlowPath1, resInICPath1); EXPECT_EQ(resInSlowPath2, resInICPath2); @@ -253,7 +243,6 @@ TEST_F(IcCompareOPTest, LessDynWithIC) EXPECT_EQ(resInSlowPath10, resInICPath10); }; - TEST_F(IcCompareOPTest, LessEqDynWithIC) { ObjectFactory *factory = ecmaVm->GetFactory(); @@ -278,40 +267,34 @@ TEST_F(IcCompareOPTest, LessEqDynWithIC) JSTaggedValue booleanObj = builtins::BuiltinsBoolean::BooleanConstructor(ecmaRuntimeCallInfo.get()); JSHandle booleanObjHandle(thread, booleanObj); - JSTaggedValue resInSlowPath1 = SlowRuntimeStub::LessEqDyn(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath2 = SlowRuntimeStub::LessEqDyn(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath3 = SlowRuntimeStub::LessEqDyn(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath4 = SlowRuntimeStub::LessEqDyn(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::LessEqDyn(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue()); - JSTaggedValue resInSlowPath9 = SlowRuntimeStub::LessEqDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null()); - JSTaggedValue resInSlowPath10 = SlowRuntimeStub::LessEqDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True()); + JSTaggedValue resInSlowPath1 = + SlowRuntimeStub::LessEqDyn(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath2 = + SlowRuntimeStub::LessEqDyn(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath3 = + SlowRuntimeStub::LessEqDyn(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath4 = + SlowRuntimeStub::LessEqDyn(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath5 = + SlowRuntimeStub::LessEqDyn(thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue()); + JSTaggedValue resInSlowPath9 = + SlowRuntimeStub::LessEqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null()); + JSTaggedValue resInSlowPath10 = + SlowRuntimeStub::LessEqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::True()); JSTaggedValue resInICPath1 = CompareOp::LessEqDynWithIC(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue(), - CompareOpType::NUMBER_NUMBER); - JSTaggedValue resInICPath2 = CompareOp::LessEqDynWithIC(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue(), + arg2Handle.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); + JSTaggedValue resInICPath2 = CompareOp::LessEqDynWithIC(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue(), CompareOpType::STRING_NUMBER); - JSTaggedValue resInICPath3 = CompareOp::LessEqDynWithIC(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue(), + JSTaggedValue resInICPath3 = CompareOp::LessEqDynWithIC(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath4 = CompareOp::LessEqDynWithIC(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue(), + JSTaggedValue resInICPath4 = CompareOp::LessEqDynWithIC(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath5 = CompareOp::LessEqDynWithIC(thread, - arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue(), - CompareOpType::NUMBER_OBJ); - JSTaggedValue resInICPath9 = CompareOp::LessEqDynWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null(), CompareOpType::UNDEFINED_NULL); - JSTaggedValue resInICPath10 = CompareOp::LessEqDynWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True(), CompareOpType::OTHER); + JSTaggedValue resInICPath5 = CompareOp::LessEqDynWithIC( + thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue(), CompareOpType::NUMBER_OBJ); + JSTaggedValue resInICPath9 = CompareOp::LessEqDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null(), + CompareOpType::UNDEFINED_NULL); + JSTaggedValue resInICPath10 = + CompareOp::LessEqDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::True(), CompareOpType::OTHER); EXPECT_EQ(resInSlowPath1, resInICPath1); EXPECT_EQ(resInSlowPath2, resInICPath2); @@ -322,7 +305,6 @@ TEST_F(IcCompareOPTest, LessEqDynWithIC) EXPECT_EQ(resInSlowPath10, resInICPath10); }; - TEST_F(IcCompareOPTest, GreaterDynWithIC) { ObjectFactory *factory = ecmaVm->GetFactory(); @@ -347,40 +329,35 @@ TEST_F(IcCompareOPTest, GreaterDynWithIC) JSTaggedValue booleanObj = builtins::BuiltinsBoolean::BooleanConstructor(ecmaRuntimeCallInfo.get()); JSHandle booleanObjHandle(thread, booleanObj); - JSTaggedValue resInSlowPath1 = SlowRuntimeStub::GreaterDyn(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath2 = SlowRuntimeStub::GreaterDyn(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath3 = SlowRuntimeStub::GreaterDyn(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath4 = SlowRuntimeStub::GreaterDyn(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::GreaterDyn(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue()); - JSTaggedValue resInSlowPath9 = SlowRuntimeStub::GreaterDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null()); - JSTaggedValue resInSlowPath10 = SlowRuntimeStub::GreaterDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True()); + JSTaggedValue resInSlowPath1 = + SlowRuntimeStub::GreaterDyn(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath2 = + SlowRuntimeStub::GreaterDyn(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath3 = + SlowRuntimeStub::GreaterDyn(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath4 = + SlowRuntimeStub::GreaterDyn(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath5 = + SlowRuntimeStub::GreaterDyn(thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue()); + JSTaggedValue resInSlowPath9 = + SlowRuntimeStub::GreaterDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null()); + JSTaggedValue resInSlowPath10 = + SlowRuntimeStub::GreaterDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::True()); JSTaggedValue resInICPath1 = CompareOp::GreaterDynWithIC(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue(), - CompareOpType::NUMBER_NUMBER); - JSTaggedValue resInICPath2 = CompareOp::GreaterDynWithIC(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue(), + arg2Handle.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); + JSTaggedValue resInICPath2 = CompareOp::GreaterDynWithIC(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue(), CompareOpType::STRING_NUMBER); - JSTaggedValue resInICPath3 = CompareOp::GreaterDynWithIC(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue(), + JSTaggedValue resInICPath3 = CompareOp::GreaterDynWithIC(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath4 = CompareOp::GreaterDynWithIC(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue(), + JSTaggedValue resInICPath4 = CompareOp::GreaterDynWithIC(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath5 = CompareOp::GreaterDynWithIC(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue(), - CompareOpType::NUMBER_OBJ); - JSTaggedValue resInICPath9 = CompareOp::GreaterDynWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null(), CompareOpType::UNDEFINED_NULL); - JSTaggedValue resInICPath10 = CompareOp::GreaterDynWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True(), CompareOpType::OTHER); + JSTaggedValue resInICPath5 = CompareOp::GreaterDynWithIC( + thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue(), CompareOpType::NUMBER_OBJ); + JSTaggedValue resInICPath9 = CompareOp::GreaterDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null(), + CompareOpType::UNDEFINED_NULL); + JSTaggedValue resInICPath10 = + CompareOp::GreaterDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::True(), CompareOpType::OTHER); EXPECT_EQ(resInSlowPath1, resInICPath1); EXPECT_EQ(resInSlowPath2, resInICPath2); @@ -391,7 +368,6 @@ TEST_F(IcCompareOPTest, GreaterDynWithIC) EXPECT_EQ(resInSlowPath10, resInICPath10); }; - TEST_F(IcCompareOPTest, GreaterEqDynWithIC) { ObjectFactory *factory = ecmaVm->GetFactory(); @@ -417,40 +393,35 @@ TEST_F(IcCompareOPTest, GreaterEqDynWithIC) JSTaggedValue booleanObj = builtins::BuiltinsBoolean::BooleanConstructor(ecmaRuntimeCallInfo.get()); JSHandle booleanObjHandle(thread, booleanObj); - JSTaggedValue resInSlowPath1 = SlowRuntimeStub::GreaterEqDyn(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath2 = SlowRuntimeStub::GreaterEqDyn(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath3 = SlowRuntimeStub::GreaterEqDyn(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath4 = SlowRuntimeStub::GreaterEqDyn(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue()); - JSTaggedValue resInSlowPath5 = SlowRuntimeStub::GreaterEqDyn(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue()); - JSTaggedValue resInSlowPath9 = SlowRuntimeStub::GreaterEqDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::Null()); - JSTaggedValue resInSlowPath10 = SlowRuntimeStub::GreaterEqDyn(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True()); - - JSTaggedValue resInICPath1 = CompareOp::GreaterEqDynWithIC(thread, arg1Handle.GetTaggedValue(), - arg2Handle.GetTaggedValue(), - CompareOpType::NUMBER_NUMBER); - JSTaggedValue resInICPath2 = CompareOp::GreaterEqDynWithIC(thread, Str1.GetTaggedValue(), - arg1Handle.GetTaggedValue(), - CompareOpType::STRING_NUMBER); - JSTaggedValue resInICPath3 = CompareOp::GreaterEqDynWithIC(thread, Str1.GetTaggedValue(), - arg3Handle.GetTaggedValue(), - CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath4 = CompareOp::GreaterEqDynWithIC(thread, Str1.GetTaggedValue(), - arg4Handle.GetTaggedValue(), - CompareOpType::STRING_BOOLEAN); - JSTaggedValue resInICPath5 = CompareOp::GreaterEqDynWithIC(thread, arg1Handle.GetTaggedValue(), - booleanObjHandle.GetTaggedValue(), - CompareOpType::NUMBER_OBJ); + JSTaggedValue resInSlowPath1 = + SlowRuntimeStub::GreaterEqDyn(thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath2 = + SlowRuntimeStub::GreaterEqDyn(thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath3 = + SlowRuntimeStub::GreaterEqDyn(thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath4 = + SlowRuntimeStub::GreaterEqDyn(thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue()); + JSTaggedValue resInSlowPath5 = + SlowRuntimeStub::GreaterEqDyn(thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue()); + JSTaggedValue resInSlowPath9 = + SlowRuntimeStub::GreaterEqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null()); + JSTaggedValue resInSlowPath10 = + SlowRuntimeStub::GreaterEqDyn(thread, JSTaggedValue::Undefined(), JSTaggedValue::True()); + + JSTaggedValue resInICPath1 = CompareOp::GreaterEqDynWithIC( + thread, arg1Handle.GetTaggedValue(), arg2Handle.GetTaggedValue(), CompareOpType::NUMBER_NUMBER); + JSTaggedValue resInICPath2 = CompareOp::GreaterEqDynWithIC( + thread, Str1.GetTaggedValue(), arg1Handle.GetTaggedValue(), CompareOpType::STRING_NUMBER); + JSTaggedValue resInICPath3 = CompareOp::GreaterEqDynWithIC( + thread, Str1.GetTaggedValue(), arg3Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath4 = CompareOp::GreaterEqDynWithIC( + thread, Str1.GetTaggedValue(), arg4Handle.GetTaggedValue(), CompareOpType::STRING_BOOLEAN); + JSTaggedValue resInICPath5 = CompareOp::GreaterEqDynWithIC( + thread, arg1Handle.GetTaggedValue(), booleanObjHandle.GetTaggedValue(), CompareOpType::NUMBER_OBJ); JSTaggedValue resInICPath9 = CompareOp::GreaterEqDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::Null(), CompareOpType::UNDEFINED_NULL); - JSTaggedValue resInICPath10 = CompareOp::GreaterEqDynWithIC(thread, JSTaggedValue::Undefined(), - JSTaggedValue::True(), CompareOpType::OTHER); + JSTaggedValue resInICPath10 = + CompareOp::GreaterEqDynWithIC(thread, JSTaggedValue::Undefined(), JSTaggedValue::True(), CompareOpType::OTHER); EXPECT_EQ(resInSlowPath1, resInICPath1); EXPECT_EQ(resInSlowPath2, resInICPath2); diff --git a/tests/runtime/ic/ic_invoke_test.cpp b/tests/runtime/ic/ic_invoke_test.cpp index d41138a7c..2fd40d355 100644 --- a/tests/runtime/ic/ic_invoke_test.cpp +++ b/tests/runtime/ic/ic_invoke_test.cpp @@ -61,8 +61,8 @@ TEST_F(ICInvokeTest, SetMonoConstuctCacheSlot) JSHandle array = factory->NewTaggedArray(10); uint32_t slotId = 5; - bool setResult = InvokeCache::SetMonoConstuctCacheSlot( - thread, static_cast(*array), slotId, func.GetTaggedValue(), JSTaggedValue(123)); + bool setResult = InvokeCache::SetMonoConstuctCacheSlot(thread, static_cast(*array), slotId, + func.GetTaggedValue(), JSTaggedValue(123)); ASSERT_TRUE(setResult); ASSERT_EQ(array->Get(thread, slotId), func.GetTaggedValue()); ASSERT_EQ(array->Get(thread, slotId + 1), JSTaggedValue(123)); @@ -90,8 +90,8 @@ TEST_F(ICInvokeTest, SetPolyConstuctCacheSlot) JSHandle array = factory->NewTaggedArray(10); uint32_t slotId = 5; - bool setResult = InvokeCache::SetPolyConstuctCacheSlot( - thread, static_cast(*array), slotId, 3, array1.GetTaggedValue(), array2.GetTaggedValue()); + bool setResult = InvokeCache::SetPolyConstuctCacheSlot(thread, static_cast(*array), slotId, 3, + array1.GetTaggedValue(), array2.GetTaggedValue()); ASSERT_TRUE(setResult); JSTaggedValue slot = array->Get(thread, slotId); ASSERT_TRUE(slot.IsTaggedArray()); @@ -131,4 +131,4 @@ TEST_F(ICInvokeTest, CheckPolyInvokeCache) JSTaggedValue testValue3 = InvokeCache::CheckPolyInvokeCache(array.GetTaggedValue(), func3.GetTaggedValue()); ASSERT_EQ(testValue3, JSTaggedValue::Hole()); } -} +} // namespace panda::test diff --git a/tests/runtime/mem/g1gc_barrier_test.cpp b/tests/runtime/mem/g1gc_barrier_test.cpp index 3112911e4..8cda01f84 100644 --- a/tests/runtime/mem/g1gc_barrier_test.cpp +++ b/tests/runtime/mem/g1gc_barrier_test.cpp @@ -54,8 +54,8 @@ public: { size_t size = TaggedArray::ComputeSize(JSTaggedValue::TaggedTypeSize(), length); mem::HeapManager *heap_manager = thread_->GetVM()->GetHeapManager(); - auto *array = reinterpret_cast(heap_manager->AllocateObject( - array_class_->GetHClass(), size, DEFAULT_ALIGNMENT, thread_)); + auto *array = reinterpret_cast( + heap_manager->AllocateObject(array_class_->GetHClass(), size, DEFAULT_ALIGNMENT, thread_)); array->SetLength(length); return array; } @@ -67,8 +67,8 @@ public: class ConcurrentMarkListener : public mem::GCListener { public: - ConcurrentMarkListener(G1GCBarrierTest *test, JSHandle array, - JSHandle object, JSHandle replacement) + ConcurrentMarkListener(G1GCBarrierTest *test, JSHandle array, JSHandle object, + JSHandle replacement) : test_(test), array_(array), object_(object), replacement_(replacement) { } @@ -106,7 +106,7 @@ TEST_F(G1GCBarrierTest, TestPreBarrier) JSHandle array(thread_, AllocArray(2)); JSHandle obj(thread_, AllocObject()); JSHandle replacement(thread_, AllocObject()); - array->Set(thread_, 0, obj.GetTaggedValue()); // test object -> undefined + array->Set(thread_, 0, obj.GetTaggedValue()); // test object -> undefined array->Set(thread_, 1, JSTaggedValue::Undefined()); // test undefined -> object ConcurrentMarkListener listener(this, array, obj, replacement); @@ -116,4 +116,4 @@ TEST_F(G1GCBarrierTest, TestPreBarrier) task.Run(*gc); ASSERT_TRUE(listener.has_concurrent_mark); } -} // namespace panda::mem +} // namespace panda::ecmascript diff --git a/tests/runtime/mem/weak_containers_test.cpp b/tests/runtime/mem/weak_containers_test.cpp index d24f766a5..cbc3e26e0 100644 --- a/tests/runtime/mem/weak_containers_test.cpp +++ b/tests/runtime/mem/weak_containers_test.cpp @@ -71,7 +71,7 @@ Local GetContainerSize(EcmaVM *vm, Local, const LocalGetTaggedObject()->GetClass(); - if (!hclass->IsJSWeakMap() && ! hclass->IsJSWeakSet()) { + if (!hclass->IsJSWeakMap() && !hclass->IsJSWeakSet()) { LOG_ECMA(FATAL) << "Argument is not weak container"; } if (hclass->IsJSWeakMap()) { @@ -95,7 +95,8 @@ bool RegisterFunction(EcmaVM *vm, Local &globalObject, panda::Functio return result; } -TEST_F(WeakContainersTests, WeakContainers) { +TEST_F(WeakContainersTests, WeakContainers) +{ const char mainFunc[] = "_GLOBAL::func_main_0"; JSExecutionScope executionScope(vm_); LocalScope scope(vm_); @@ -115,4 +116,4 @@ TEST_F(WeakContainersTests, WeakContainers) { FAIL() << msg->ToString(); } } -} +} // namespace panda::test diff --git a/tests/runtime/napi/jsnapi_tests.cpp b/tests/runtime/napi/jsnapi_tests.cpp index f434863e5..8b8956210 100644 --- a/tests/runtime/napi/jsnapi_tests.cpp +++ b/tests/runtime/napi/jsnapi_tests.cpp @@ -79,8 +79,8 @@ public: Local GetMethod(Local obj, Local key) { - JSHandle val = JSObject::GetMethod(thread_, JSNApiHelper::ToJSHandle(obj), - JSNApiHelper::ToJSHandle(key)); + JSHandle val = + JSObject::GetMethod(thread_, JSNApiHelper::ToJSHandle(obj), JSNApiHelper::ToJSHandle(key)); return JSNApiHelper::ToLocal(val); } @@ -679,8 +679,8 @@ TEST_F(JSNApiTests, InheritPrototype_001) ASSERT_FALSE(same1); // Set property to Set Function - Local defaultString = JSNApiHelper::ToLocal( - thread_->GlobalConstants()->GetHandledDefaultString()); + Local defaultString = + JSNApiHelper::ToLocal(thread_->GlobalConstants()->GetHandledDefaultString()); { PropertyAttribute attr(defaultString, true, true, true); ASSERT_TRUE(setLocal->DefineProperty(vm_, defaultString, attr)); @@ -766,8 +766,8 @@ TEST_F(JSNApiTests, InheritPrototype_003) JSHandle sonHandle = JSHandle::Cast(JSNApiHelper::ToJSHandle(noProtoLocal)); EXPECT_FALSE(sonHandle->HasFunctionPrototype()); - Local defaultString = JSNApiHelper::ToLocal( - thread_->GlobalConstants()->GetHandledDefaultString()); + Local defaultString = + JSNApiHelper::ToLocal(thread_->GlobalConstants()->GetHandledDefaultString()); { PropertyAttribute attr(defaultString, true, true, true); protoLocal->DefineProperty(vm_, defaultString, attr); diff --git a/tests/runtime/snapshot/snapshot_test.cpp b/tests/runtime/snapshot/snapshot_test.cpp index 483634add..c531d65c5 100644 --- a/tests/runtime/snapshot/snapshot_test.cpp +++ b/tests/runtime/snapshot/snapshot_test.cpp @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #include "gtest/gtest.h" #include "test_helper.h" @@ -46,7 +46,5 @@ public: JSThread *thread; }; -TEST_F(SnapShotTest, Serialize) -{ -} +TEST_F(SnapShotTest, Serialize) {} } // namespace panda::test diff --git a/tests/runtime/tooling/CMakeLists.txt b/tests/runtime/tooling/CMakeLists.txt index 8617dbc0e..5133ffa7a 100644 --- a/tests/runtime/tooling/CMakeLists.txt +++ b/tests/runtime/tooling/CMakeLists.txt @@ -56,5 +56,3 @@ add_gtests( arkruntime_ecmascript_options_test options_test/options_test.cpp ) - -add_check_style(".") -- Gitee