1/** 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16% Panda::instructions.select{|b| b.namespace == "ecmascript"}.each do |inst| 17 case RuntimeInterface::IntrinsicId::DYN_<%= inst.opcode.upcase %>: 18 { 19 constexpr auto CLEAR_FLAGS = ark::compiler::inst_flags::BARRIER|ark::compiler::inst_flags::REQUIRE_STATE|ark::compiler::inst_flags::CALL|ark::compiler::inst_flags::HEAP_INV|ark::compiler::inst_flags::CAN_THROW|ark::compiler::inst_flags::ACC_READ|ark::compiler::inst_flags::ACC_WRITE; 20 constexpr auto SET_FLAGS = 0U; 21 static_assert((SET_FLAGS & CLEAR_FLAGS) == 0, "DYN_<%= inst.opcode.upcase %> CLEAR_FLAGS cannot intersect SET_FLAGS"); 22 inst->ClearFlag(static_cast<inst_flags::Flags>(CLEAR_FLAGS)); 23% if inst.throwing? 24 inst->SetFlag(ark::compiler::inst_flags::CAN_THROW); 25% end 26% if inst.exceptions.include?('x_throw') || inst.properties.include?('return') 27 inst->SetFlag(ark::compiler::inst_flags::CF); 28 inst->SetFlag(ark::compiler::inst_flags::TERMINATOR); 29% end 30% if inst.acc.include?("in") 31 inst->SetFlag(ark::compiler::inst_flags::ACC_READ); 32% end 33% addition_acc_write_opcodes = ["DEFINEPROPERTYBYNAME_IMM8_ID16_V8", 34% "CALLRUNTIME_DEFINEFIELDBYVALUE_PREF_IMM8_V8_V8", 35% "CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8", 36% "STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8", 37% "THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16"] 38% if inst.acc.include?("out") || (addition_acc_write_opcodes.include? inst.opcode.upcase) 39 inst->SetFlag(ark::compiler::inst_flags::ACC_WRITE); 40% end 41 break; 42 } 43% end 44