Op.h 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938
  1. /*
  2. * Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  4. * Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <AK/FixedArray.h>
  10. #include <AK/StdLibExtras.h>
  11. #include <LibCrypto/BigInt/SignedBigInteger.h>
  12. #include <LibJS/Bytecode/Builtins.h>
  13. #include <LibJS/Bytecode/IdentifierTable.h>
  14. #include <LibJS/Bytecode/Instruction.h>
  15. #include <LibJS/Bytecode/Label.h>
  16. #include <LibJS/Bytecode/Operand.h>
  17. #include <LibJS/Bytecode/RegexTable.h>
  18. #include <LibJS/Bytecode/Register.h>
  19. #include <LibJS/Bytecode/StringTable.h>
  20. #include <LibJS/Heap/Cell.h>
  21. #include <LibJS/Runtime/Environment.h>
  22. #include <LibJS/Runtime/Iterator.h>
  23. #include <LibJS/Runtime/Value.h>
  24. #include <LibJS/Runtime/ValueTraits.h>
  25. namespace JS {
  26. class FunctionExpression;
  27. }
  28. namespace JS::Bytecode::Op {
  29. class Mov final : public Instruction {
  30. public:
  31. Mov(Operand dst, Operand src)
  32. : Instruction(Type::Mov, sizeof(*this))
  33. , m_dst(dst)
  34. , m_src(src)
  35. {
  36. }
  37. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  38. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  39. Operand dst() const { return m_dst; }
  40. Operand src() const { return m_src; }
  41. private:
  42. Operand m_dst;
  43. Operand m_src;
  44. };
  45. #define JS_ENUMERATE_COMMON_BINARY_OPS_WITH_FAST_PATH(O) \
  46. O(Add, add) \
  47. O(BitwiseAnd, bitwise_and) \
  48. O(BitwiseOr, bitwise_or) \
  49. O(BitwiseXor, bitwise_xor) \
  50. O(GreaterThan, greater_than) \
  51. O(GreaterThanEquals, greater_than_equals) \
  52. O(LessThan, less_than) \
  53. O(LessThanEquals, less_than_equals) \
  54. O(Mul, mul) \
  55. O(RightShift, right_shift) \
  56. O(Sub, sub) \
  57. O(UnsignedRightShift, unsigned_right_shift)
  58. #define JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(O) \
  59. O(Div, div) \
  60. O(Exp, exp) \
  61. O(Mod, mod) \
  62. O(In, in) \
  63. O(InstanceOf, instance_of) \
  64. O(LooselyInequals, loosely_inequals) \
  65. O(LooselyEquals, loosely_equals) \
  66. O(StrictlyInequals, strict_inequals) \
  67. O(StrictlyEquals, strict_equals) \
  68. O(LeftShift, left_shift)
  69. #define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
  70. class OpTitleCase final : public Instruction { \
  71. public: \
  72. explicit OpTitleCase(Operand dst, Operand lhs, Operand rhs) \
  73. : Instruction(Type::OpTitleCase, sizeof(*this)) \
  74. , m_dst(dst) \
  75. , m_lhs(lhs) \
  76. , m_rhs(rhs) \
  77. { \
  78. } \
  79. \
  80. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
  81. ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
  82. \
  83. Operand dst() const { return m_dst; } \
  84. Operand lhs() const { return m_lhs; } \
  85. Operand rhs() const { return m_rhs; } \
  86. \
  87. private: \
  88. Operand m_dst; \
  89. Operand m_lhs; \
  90. Operand m_rhs; \
  91. };
  92. JS_ENUMERATE_COMMON_BINARY_OPS_WITHOUT_FAST_PATH(JS_DECLARE_COMMON_BINARY_OP)
  93. JS_ENUMERATE_COMMON_BINARY_OPS_WITH_FAST_PATH(JS_DECLARE_COMMON_BINARY_OP)
  94. #undef JS_DECLARE_COMMON_BINARY_OP
  95. #define JS_ENUMERATE_COMMON_UNARY_OPS(O) \
  96. O(BitwiseNot, bitwise_not) \
  97. O(Not, not_) \
  98. O(UnaryPlus, unary_plus) \
  99. O(UnaryMinus, unary_minus) \
  100. O(Typeof, typeof_)
  101. #define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
  102. class OpTitleCase final : public Instruction { \
  103. public: \
  104. OpTitleCase(Operand dst, Operand src) \
  105. : Instruction(Type::OpTitleCase, sizeof(*this)) \
  106. , m_dst(dst) \
  107. , m_src(src) \
  108. { \
  109. } \
  110. \
  111. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
  112. ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
  113. \
  114. Operand dst() const { return m_dst; } \
  115. Operand src() const { return m_src; } \
  116. \
  117. private: \
  118. Operand m_dst; \
  119. Operand m_src; \
  120. };
  121. JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
  122. #undef JS_DECLARE_COMMON_UNARY_OP
  123. class NewString final : public Instruction {
  124. public:
  125. NewString(Operand dst, StringTableIndex string)
  126. : Instruction(Type::NewString, sizeof(*this))
  127. , m_dst(dst)
  128. , m_string(string)
  129. {
  130. }
  131. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  132. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  133. Operand dst() const { return m_dst; }
  134. StringTableIndex index() const { return m_string; }
  135. private:
  136. Operand m_dst;
  137. StringTableIndex m_string;
  138. };
  139. class NewObject final : public Instruction {
  140. public:
  141. explicit NewObject(Operand dst)
  142. : Instruction(Type::NewObject, sizeof(*this))
  143. , m_dst(dst)
  144. {
  145. }
  146. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  147. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  148. Operand dst() const { return m_dst; }
  149. private:
  150. Operand m_dst;
  151. };
  152. class NewRegExp final : public Instruction {
  153. public:
  154. NewRegExp(Operand dst, StringTableIndex source_index, StringTableIndex flags_index, RegexTableIndex regex_index)
  155. : Instruction(Type::NewRegExp, sizeof(*this))
  156. , m_dst(dst)
  157. , m_source_index(source_index)
  158. , m_flags_index(flags_index)
  159. , m_regex_index(regex_index)
  160. {
  161. }
  162. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  163. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  164. Operand dst() const { return m_dst; }
  165. StringTableIndex source_index() const { return m_source_index; }
  166. StringTableIndex flags_index() const { return m_flags_index; }
  167. RegexTableIndex regex_index() const { return m_regex_index; }
  168. private:
  169. Operand m_dst;
  170. StringTableIndex m_source_index;
  171. StringTableIndex m_flags_index;
  172. RegexTableIndex m_regex_index;
  173. };
  174. #define JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(O) \
  175. O(TypeError)
  176. #define JS_DECLARE_NEW_BUILTIN_ERROR_OP(ErrorName) \
  177. class New##ErrorName final : public Instruction { \
  178. public: \
  179. New##ErrorName(Operand dst, StringTableIndex error_string) \
  180. : Instruction(Type::New##ErrorName, sizeof(*this)) \
  181. , m_dst(dst) \
  182. , m_error_string(error_string) \
  183. { \
  184. } \
  185. \
  186. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
  187. ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
  188. \
  189. Operand dst() const { return m_dst; } \
  190. StringTableIndex error_string() const { return m_error_string; } \
  191. \
  192. private: \
  193. Operand m_dst; \
  194. StringTableIndex m_error_string; \
  195. };
  196. JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(JS_DECLARE_NEW_BUILTIN_ERROR_OP)
  197. #undef JS_DECLARE_NEW_BUILTIN_ERROR_OP
  198. // NOTE: This instruction is variable-width depending on the number of excluded names
  199. class CopyObjectExcludingProperties final : public Instruction {
  200. public:
  201. CopyObjectExcludingProperties(Operand dst, Operand from_object, Vector<Operand> const& excluded_names)
  202. : Instruction(Type::CopyObjectExcludingProperties, length_impl(excluded_names.size()))
  203. , m_dst(dst)
  204. , m_from_object(from_object)
  205. , m_excluded_names_count(excluded_names.size())
  206. {
  207. for (size_t i = 0; i < m_excluded_names_count; i++)
  208. m_excluded_names[i] = excluded_names[i];
  209. }
  210. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  211. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  212. size_t length_impl(size_t excluded_names_count) const
  213. {
  214. return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * excluded_names_count);
  215. }
  216. Operand dst() const { return m_dst; }
  217. Operand from_object() const { return m_from_object; }
  218. size_t excluded_names_count() const { return m_excluded_names_count; }
  219. Operand const* excluded_names() const { return m_excluded_names; }
  220. private:
  221. Operand m_dst;
  222. Operand m_from_object;
  223. size_t m_excluded_names_count { 0 };
  224. Operand m_excluded_names[];
  225. };
  226. class NewBigInt final : public Instruction {
  227. public:
  228. NewBigInt(Operand dst, Crypto::SignedBigInteger bigint)
  229. : Instruction(Type::NewBigInt, sizeof(*this))
  230. , m_dst(dst)
  231. , m_bigint(move(bigint))
  232. {
  233. }
  234. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  235. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  236. Operand dst() const { return m_dst; }
  237. Crypto::SignedBigInteger const& bigint() const { return m_bigint; }
  238. private:
  239. Operand m_dst;
  240. Crypto::SignedBigInteger m_bigint;
  241. };
  242. // NOTE: This instruction is variable-width depending on the number of elements!
  243. class NewArray final : public Instruction {
  244. public:
  245. explicit NewArray(Operand dst)
  246. : Instruction(Type::NewArray, length_impl(0))
  247. , m_dst(dst)
  248. , m_element_count(0)
  249. {
  250. }
  251. NewArray(Operand dst, AK::Array<Operand, 2> const& elements_range)
  252. : Instruction(Type::NewArray, length_impl(elements_range[1].index() - elements_range[0].index() + 1))
  253. , m_dst(dst)
  254. , m_element_count(elements_range[1].index() - elements_range[0].index() + 1)
  255. {
  256. m_elements[0] = elements_range[0];
  257. m_elements[1] = elements_range[1];
  258. }
  259. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  260. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  261. Operand dst() const { return m_dst; }
  262. size_t length_impl(size_t element_count) const
  263. {
  264. return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * (element_count == 0 ? 0 : 2));
  265. }
  266. Operand start() const
  267. {
  268. VERIFY(m_element_count);
  269. return m_elements[0];
  270. }
  271. Operand end() const
  272. {
  273. VERIFY(m_element_count);
  274. return m_elements[1];
  275. }
  276. size_t element_count() const { return m_element_count; }
  277. private:
  278. Operand m_dst;
  279. size_t m_element_count { 0 };
  280. Operand m_elements[];
  281. };
  282. class NewPrimitiveArray final : public Instruction {
  283. public:
  284. NewPrimitiveArray(Operand dst, FixedArray<Value> values)
  285. : Instruction(Type::NewPrimitiveArray, sizeof(*this))
  286. , m_dst(dst)
  287. , m_values(move(values))
  288. {
  289. }
  290. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  291. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  292. Operand dst() const { return m_dst; }
  293. ReadonlySpan<Value> values() const { return m_values.span(); }
  294. private:
  295. Operand m_dst;
  296. FixedArray<Value> m_values;
  297. };
  298. class ArrayAppend final : public Instruction {
  299. public:
  300. ArrayAppend(Operand dst, Operand src, bool is_spread)
  301. : Instruction(Type::ArrayAppend, sizeof(*this))
  302. , m_dst(dst)
  303. , m_src(src)
  304. , m_is_spread(is_spread)
  305. {
  306. }
  307. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  308. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  309. Operand dst() const { return m_dst; }
  310. Operand src() const { return m_src; }
  311. bool is_spread() const { return m_is_spread; }
  312. private:
  313. Operand m_dst;
  314. Operand m_src;
  315. bool m_is_spread = false;
  316. };
  317. class ImportCall final : public Instruction {
  318. public:
  319. ImportCall(Operand dst, Operand specifier, Operand options)
  320. : Instruction(Type::ImportCall, sizeof(*this))
  321. , m_dst(dst)
  322. , m_specifier(specifier)
  323. , m_options(options)
  324. {
  325. }
  326. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  327. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  328. Operand dst() const { return m_dst; }
  329. Operand specifier() const { return m_specifier; }
  330. Operand options() const { return m_options; }
  331. private:
  332. Operand m_dst;
  333. Operand m_specifier;
  334. Operand m_options;
  335. };
  336. class IteratorToArray final : public Instruction {
  337. public:
  338. explicit IteratorToArray(Operand dst, Operand iterator)
  339. : Instruction(Type::IteratorToArray, sizeof(*this))
  340. , m_dst(dst)
  341. , m_iterator(iterator)
  342. {
  343. }
  344. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  345. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  346. Operand dst() const { return m_dst; }
  347. Operand iterator() const { return m_iterator; }
  348. private:
  349. Operand m_dst;
  350. Operand m_iterator;
  351. };
  352. class ConcatString final : public Instruction {
  353. public:
  354. explicit ConcatString(Operand dst, Operand src)
  355. : Instruction(Type::ConcatString, sizeof(*this))
  356. , m_dst(dst)
  357. , m_src(src)
  358. {
  359. }
  360. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  361. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  362. Operand dst() const { return m_dst; }
  363. Operand src() const { return m_src; }
  364. private:
  365. Operand m_dst;
  366. Operand m_src;
  367. };
  368. enum class EnvironmentMode {
  369. Lexical,
  370. Var,
  371. };
  372. class CreateLexicalEnvironment final : public Instruction {
  373. public:
  374. explicit CreateLexicalEnvironment()
  375. : Instruction(Type::CreateLexicalEnvironment, sizeof(*this))
  376. {
  377. }
  378. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  379. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  380. };
  381. class EnterObjectEnvironment final : public Instruction {
  382. public:
  383. explicit EnterObjectEnvironment(Operand object)
  384. : Instruction(Type::EnterObjectEnvironment, sizeof(*this))
  385. , m_object(object)
  386. {
  387. }
  388. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  389. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  390. Operand object() const { return m_object; }
  391. private:
  392. Operand m_object;
  393. };
  394. class Catch final : public Instruction {
  395. public:
  396. explicit Catch(Operand dst)
  397. : Instruction(Type::Catch, sizeof(*this))
  398. , m_dst(dst)
  399. {
  400. }
  401. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  402. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  403. Operand dst() const { return m_dst; }
  404. private:
  405. Operand m_dst;
  406. };
  407. class CreateVariable final : public Instruction {
  408. public:
  409. explicit CreateVariable(IdentifierTableIndex identifier, EnvironmentMode mode, bool is_immutable, bool is_global = false, bool is_strict = false)
  410. : Instruction(Type::CreateVariable, sizeof(*this))
  411. , m_identifier(identifier)
  412. , m_mode(mode)
  413. , m_is_immutable(is_immutable)
  414. , m_is_global(is_global)
  415. , m_is_strict(is_strict)
  416. {
  417. }
  418. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  419. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  420. IdentifierTableIndex identifier() const { return m_identifier; }
  421. EnvironmentMode mode() const { return m_mode; }
  422. bool is_immutable() const { return m_is_immutable; }
  423. bool is_global() const { return m_is_global; }
  424. bool is_strict() const { return m_is_strict; }
  425. private:
  426. IdentifierTableIndex m_identifier;
  427. EnvironmentMode m_mode;
  428. bool m_is_immutable : 4 { false };
  429. bool m_is_global : 4 { false };
  430. bool m_is_strict { false };
  431. };
  432. class SetVariable final : public Instruction {
  433. public:
  434. enum class InitializationMode {
  435. Initialize,
  436. Set,
  437. };
  438. explicit SetVariable(IdentifierTableIndex identifier, Operand src, u32 cache_index, InitializationMode initialization_mode = InitializationMode::Set, EnvironmentMode mode = EnvironmentMode::Lexical)
  439. : Instruction(Type::SetVariable, sizeof(*this))
  440. , m_identifier(identifier)
  441. , m_src(src)
  442. , m_mode(mode)
  443. , m_initialization_mode(initialization_mode)
  444. , m_cache_index(cache_index)
  445. {
  446. }
  447. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  448. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  449. IdentifierTableIndex identifier() const { return m_identifier; }
  450. Operand src() const { return m_src; }
  451. EnvironmentMode mode() const { return m_mode; }
  452. InitializationMode initialization_mode() const { return m_initialization_mode; }
  453. u32 cache_index() const { return m_cache_index; }
  454. private:
  455. IdentifierTableIndex m_identifier;
  456. Operand m_src;
  457. EnvironmentMode m_mode;
  458. InitializationMode m_initialization_mode { InitializationMode::Set };
  459. u32 m_cache_index { 0 };
  460. };
  461. class SetLocal final : public Instruction {
  462. public:
  463. SetLocal(size_t index, Operand src)
  464. : Instruction(Type::SetLocal, sizeof(*this))
  465. , m_index(index)
  466. , m_src(src)
  467. {
  468. }
  469. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  470. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  471. size_t index() const { return m_index; }
  472. Operand dst() const { return Operand(Operand::Type::Local, m_index); }
  473. Operand src() const { return m_src; }
  474. private:
  475. size_t m_index;
  476. Operand m_src;
  477. };
  478. class GetCalleeAndThisFromEnvironment final : public Instruction {
  479. public:
  480. explicit GetCalleeAndThisFromEnvironment(Operand callee, Operand this_value, IdentifierTableIndex identifier, u32 cache_index)
  481. : Instruction(Type::GetCalleeAndThisFromEnvironment, sizeof(*this))
  482. , m_identifier(identifier)
  483. , m_callee(callee)
  484. , m_this_value(this_value)
  485. , m_cache_index(cache_index)
  486. {
  487. }
  488. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  489. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  490. IdentifierTableIndex identifier() const { return m_identifier; }
  491. u32 cache_index() const { return m_cache_index; }
  492. Operand callee() const { return m_callee; }
  493. Operand this_() const { return m_this_value; }
  494. private:
  495. IdentifierTableIndex m_identifier;
  496. Operand m_callee;
  497. Operand m_this_value;
  498. u32 m_cache_index { 0 };
  499. };
  500. class GetVariable final : public Instruction {
  501. public:
  502. explicit GetVariable(Operand dst, IdentifierTableIndex identifier, u32 cache_index)
  503. : Instruction(Type::GetVariable, sizeof(*this))
  504. , m_dst(dst)
  505. , m_identifier(identifier)
  506. , m_cache_index(cache_index)
  507. {
  508. }
  509. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  510. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  511. Operand dst() const { return m_dst; }
  512. IdentifierTableIndex identifier() const { return m_identifier; }
  513. u32 cache_index() const { return m_cache_index; }
  514. private:
  515. Operand m_dst;
  516. IdentifierTableIndex m_identifier;
  517. u32 m_cache_index { 0 };
  518. };
  519. class GetGlobal final : public Instruction {
  520. public:
  521. GetGlobal(Operand dst, IdentifierTableIndex identifier, u32 cache_index)
  522. : Instruction(Type::GetGlobal, sizeof(*this))
  523. , m_dst(dst)
  524. , m_identifier(identifier)
  525. , m_cache_index(cache_index)
  526. {
  527. }
  528. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  529. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  530. Operand dst() const { return m_dst; }
  531. IdentifierTableIndex identifier() const { return m_identifier; }
  532. u32 cache_index() const { return m_cache_index; }
  533. private:
  534. Operand m_dst;
  535. IdentifierTableIndex m_identifier;
  536. u32 m_cache_index { 0 };
  537. };
  538. class DeleteVariable final : public Instruction {
  539. public:
  540. explicit DeleteVariable(Operand dst, IdentifierTableIndex identifier)
  541. : Instruction(Type::DeleteVariable, sizeof(*this))
  542. , m_dst(dst)
  543. , m_identifier(identifier)
  544. {
  545. }
  546. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  547. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  548. Operand dst() const { return m_dst; }
  549. IdentifierTableIndex identifier() const { return m_identifier; }
  550. private:
  551. Operand m_dst;
  552. IdentifierTableIndex m_identifier;
  553. };
  554. class GetById final : public Instruction {
  555. public:
  556. GetById(Operand dst, Operand base, IdentifierTableIndex property, u32 cache_index)
  557. : Instruction(Type::GetById, sizeof(*this))
  558. , m_dst(dst)
  559. , m_base(base)
  560. , m_property(property)
  561. , m_cache_index(cache_index)
  562. {
  563. }
  564. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  565. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  566. Operand dst() const { return m_dst; }
  567. Operand base() const { return m_base; }
  568. IdentifierTableIndex property() const { return m_property; }
  569. u32 cache_index() const { return m_cache_index; }
  570. private:
  571. Operand m_dst;
  572. Operand m_base;
  573. IdentifierTableIndex m_property;
  574. u32 m_cache_index { 0 };
  575. };
  576. class GetByIdWithThis final : public Instruction {
  577. public:
  578. GetByIdWithThis(Operand dst, Operand base, IdentifierTableIndex property, Operand this_value, u32 cache_index)
  579. : Instruction(Type::GetByIdWithThis, sizeof(*this))
  580. , m_dst(dst)
  581. , m_base(base)
  582. , m_property(property)
  583. , m_this_value(this_value)
  584. , m_cache_index(cache_index)
  585. {
  586. }
  587. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  588. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  589. Operand dst() const { return m_dst; }
  590. Operand base() const { return m_base; }
  591. IdentifierTableIndex property() const { return m_property; }
  592. Operand this_value() const { return m_this_value; }
  593. u32 cache_index() const { return m_cache_index; }
  594. private:
  595. Operand m_dst;
  596. Operand m_base;
  597. IdentifierTableIndex m_property;
  598. Operand m_this_value;
  599. u32 m_cache_index { 0 };
  600. };
  601. class GetPrivateById final : public Instruction {
  602. public:
  603. explicit GetPrivateById(Operand dst, Operand base, IdentifierTableIndex property)
  604. : Instruction(Type::GetPrivateById, sizeof(*this))
  605. , m_dst(dst)
  606. , m_base(base)
  607. , m_property(property)
  608. {
  609. }
  610. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  611. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  612. Operand dst() const { return m_dst; }
  613. Operand base() const { return m_base; }
  614. IdentifierTableIndex property() const { return m_property; }
  615. private:
  616. Operand m_dst;
  617. Operand m_base;
  618. IdentifierTableIndex m_property;
  619. };
  620. class HasPrivateId final : public Instruction {
  621. public:
  622. HasPrivateId(Operand dst, Operand base, IdentifierTableIndex property)
  623. : Instruction(Type::HasPrivateId, sizeof(*this))
  624. , m_dst(dst)
  625. , m_base(base)
  626. , m_property(property)
  627. {
  628. }
  629. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  630. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  631. Operand dst() const { return m_dst; }
  632. Operand base() const { return m_base; }
  633. IdentifierTableIndex property() const { return m_property; }
  634. private:
  635. Operand m_dst;
  636. Operand m_base;
  637. IdentifierTableIndex m_property;
  638. };
  639. enum class PropertyKind {
  640. Getter,
  641. Setter,
  642. KeyValue,
  643. DirectKeyValue, // Used for Object expressions. Always sets an own property, never calls a setter.
  644. Spread,
  645. ProtoSetter,
  646. };
  647. class PutById final : public Instruction {
  648. public:
  649. explicit PutById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index)
  650. : Instruction(Type::PutById, sizeof(*this))
  651. , m_base(base)
  652. , m_property(property)
  653. , m_src(src)
  654. , m_kind(kind)
  655. , m_cache_index(cache_index)
  656. {
  657. }
  658. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  659. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  660. Operand base() const { return m_base; }
  661. IdentifierTableIndex property() const { return m_property; }
  662. Operand src() const { return m_src; }
  663. PropertyKind kind() const { return m_kind; }
  664. u32 cache_index() const { return m_cache_index; }
  665. private:
  666. Operand m_base;
  667. IdentifierTableIndex m_property;
  668. Operand m_src;
  669. PropertyKind m_kind;
  670. u32 m_cache_index { 0 };
  671. };
  672. class PutByIdWithThis final : public Instruction {
  673. public:
  674. PutByIdWithThis(Operand base, Operand this_value, IdentifierTableIndex property, Operand src, PropertyKind kind, u32 cache_index)
  675. : Instruction(Type::PutByIdWithThis, sizeof(*this))
  676. , m_base(base)
  677. , m_this_value(this_value)
  678. , m_property(property)
  679. , m_src(src)
  680. , m_kind(kind)
  681. , m_cache_index(cache_index)
  682. {
  683. }
  684. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  685. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  686. Operand base() const { return m_base; }
  687. Operand this_value() const { return m_this_value; }
  688. IdentifierTableIndex property() const { return m_property; }
  689. Operand src() const { return m_src; }
  690. PropertyKind kind() const { return m_kind; }
  691. u32 cache_index() const { return m_cache_index; }
  692. private:
  693. Operand m_base;
  694. Operand m_this_value;
  695. IdentifierTableIndex m_property;
  696. Operand m_src;
  697. PropertyKind m_kind;
  698. u32 m_cache_index { 0 };
  699. };
  700. class PutPrivateById final : public Instruction {
  701. public:
  702. explicit PutPrivateById(Operand base, IdentifierTableIndex property, Operand src, PropertyKind kind = PropertyKind::KeyValue)
  703. : Instruction(Type::PutPrivateById, sizeof(*this))
  704. , m_base(base)
  705. , m_property(property)
  706. , m_src(src)
  707. , m_kind(kind)
  708. {
  709. }
  710. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  711. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  712. Operand base() const { return m_base; }
  713. IdentifierTableIndex property() const { return m_property; }
  714. Operand src() const { return m_src; }
  715. private:
  716. Operand m_base;
  717. IdentifierTableIndex m_property;
  718. Operand m_src;
  719. PropertyKind m_kind;
  720. };
  721. class DeleteById final : public Instruction {
  722. public:
  723. explicit DeleteById(Operand dst, Operand base, IdentifierTableIndex property)
  724. : Instruction(Type::DeleteById, sizeof(*this))
  725. , m_dst(dst)
  726. , m_base(base)
  727. , m_property(property)
  728. {
  729. }
  730. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  731. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  732. Operand dst() const { return m_dst; }
  733. Operand base() const { return m_base; }
  734. IdentifierTableIndex property() const { return m_property; }
  735. private:
  736. Operand m_dst;
  737. Operand m_base;
  738. IdentifierTableIndex m_property;
  739. };
  740. class DeleteByIdWithThis final : public Instruction {
  741. public:
  742. DeleteByIdWithThis(Operand dst, Operand base, Operand this_value, IdentifierTableIndex property)
  743. : Instruction(Type::DeleteByIdWithThis, sizeof(*this))
  744. , m_dst(dst)
  745. , m_base(base)
  746. , m_this_value(this_value)
  747. , m_property(property)
  748. {
  749. }
  750. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  751. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  752. Operand dst() const { return m_dst; }
  753. Operand base() const { return m_base; }
  754. Operand this_value() const { return m_this_value; }
  755. IdentifierTableIndex property() const { return m_property; }
  756. private:
  757. Operand m_dst;
  758. Operand m_base;
  759. Operand m_this_value;
  760. IdentifierTableIndex m_property;
  761. };
  762. class GetByValue final : public Instruction {
  763. public:
  764. explicit GetByValue(Operand dst, Operand base, Operand property)
  765. : Instruction(Type::GetByValue, sizeof(*this))
  766. , m_dst(dst)
  767. , m_base(base)
  768. , m_property(property)
  769. {
  770. }
  771. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  772. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  773. Operand dst() const { return m_dst; }
  774. Operand base() const { return m_base; }
  775. Operand property() const { return m_property; }
  776. private:
  777. Operand m_dst;
  778. Operand m_base;
  779. Operand m_property;
  780. };
  781. class GetByValueWithThis final : public Instruction {
  782. public:
  783. GetByValueWithThis(Operand dst, Operand base, Operand property, Operand this_value)
  784. : Instruction(Type::GetByValueWithThis, sizeof(*this))
  785. , m_dst(dst)
  786. , m_base(base)
  787. , m_property(property)
  788. , m_this_value(this_value)
  789. {
  790. }
  791. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  792. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  793. Operand dst() const { return m_dst; }
  794. Operand base() const { return m_base; }
  795. Operand property() const { return m_property; }
  796. Operand this_value() const { return m_this_value; }
  797. private:
  798. Operand m_dst;
  799. Operand m_base;
  800. Operand m_property;
  801. Operand m_this_value;
  802. };
  803. class PutByValue final : public Instruction {
  804. public:
  805. PutByValue(Operand base, Operand property, Operand src, PropertyKind kind = PropertyKind::KeyValue)
  806. : Instruction(Type::PutByValue, sizeof(*this))
  807. , m_base(base)
  808. , m_property(property)
  809. , m_src(src)
  810. , m_kind(kind)
  811. {
  812. }
  813. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  814. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  815. Operand base() const { return m_base; }
  816. Operand property() const { return m_property; }
  817. Operand src() const { return m_src; }
  818. PropertyKind kind() const { return m_kind; }
  819. private:
  820. Operand m_base;
  821. Operand m_property;
  822. Operand m_src;
  823. PropertyKind m_kind;
  824. };
  825. class PutByValueWithThis final : public Instruction {
  826. public:
  827. PutByValueWithThis(Operand base, Operand property, Operand this_value, Operand src, PropertyKind kind = PropertyKind::KeyValue)
  828. : Instruction(Type::PutByValueWithThis, sizeof(*this))
  829. , m_base(base)
  830. , m_property(property)
  831. , m_this_value(this_value)
  832. , m_src(src)
  833. , m_kind(kind)
  834. {
  835. }
  836. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  837. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  838. Operand base() const { return m_base; }
  839. Operand property() const { return m_property; }
  840. Operand this_value() const { return m_this_value; }
  841. Operand src() const { return m_src; }
  842. PropertyKind kind() const { return m_kind; }
  843. private:
  844. Operand m_base;
  845. Operand m_property;
  846. Operand m_this_value;
  847. Operand m_src;
  848. PropertyKind m_kind;
  849. };
  850. class DeleteByValue final : public Instruction {
  851. public:
  852. DeleteByValue(Operand dst, Operand base, Operand property)
  853. : Instruction(Type::DeleteByValue, sizeof(*this))
  854. , m_dst(dst)
  855. , m_base(base)
  856. , m_property(property)
  857. {
  858. }
  859. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  860. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  861. Operand dst() const { return m_dst; }
  862. Operand base() const { return m_base; }
  863. Operand property() const { return m_property; }
  864. private:
  865. Operand m_dst;
  866. Operand m_base;
  867. Operand m_property;
  868. };
  869. class DeleteByValueWithThis final : public Instruction {
  870. public:
  871. DeleteByValueWithThis(Operand dst, Operand base, Operand this_value, Operand property)
  872. : Instruction(Type::DeleteByValueWithThis, sizeof(*this))
  873. , m_dst(dst)
  874. , m_base(base)
  875. , m_this_value(this_value)
  876. , m_property(property)
  877. {
  878. }
  879. Operand dst() const { return m_dst; }
  880. Operand base() const { return m_base; }
  881. Operand this_value() const { return m_this_value; }
  882. Operand property() const { return m_property; }
  883. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  884. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  885. private:
  886. Operand m_dst;
  887. Operand m_base;
  888. Operand m_this_value;
  889. Operand m_property;
  890. };
  891. class Jump : public Instruction {
  892. public:
  893. constexpr static bool IsTerminator = true;
  894. explicit Jump(Type type, Label taken_target, Optional<Label> nontaken_target = {})
  895. : Instruction(type, sizeof(*this))
  896. , m_true_target(move(taken_target))
  897. , m_false_target(move(nontaken_target))
  898. {
  899. }
  900. explicit Jump(Type type, Label taken_target, Label nontaken_target, size_t sizeof_self)
  901. : Instruction(type, sizeof_self)
  902. , m_true_target(move(taken_target))
  903. , m_false_target(move(nontaken_target))
  904. {
  905. }
  906. explicit Jump(Label taken_target, Optional<Label> nontaken_target = {})
  907. : Instruction(Type::Jump, sizeof(*this))
  908. , m_true_target(move(taken_target))
  909. , m_false_target(move(nontaken_target))
  910. {
  911. }
  912. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  913. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  914. auto& true_target() const { return m_true_target; }
  915. auto& false_target() const { return m_false_target; }
  916. protected:
  917. Optional<Label> m_true_target;
  918. Optional<Label> m_false_target;
  919. };
  920. class JumpIf final : public Jump {
  921. public:
  922. explicit JumpIf(Operand condition, Label true_target, Label false_target)
  923. : Jump(Type::JumpIf, move(true_target), move(false_target), sizeof(*this))
  924. , m_condition(condition)
  925. {
  926. }
  927. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  928. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  929. Operand condition() const { return m_condition; }
  930. private:
  931. Operand m_condition;
  932. };
  933. class JumpNullish final : public Jump {
  934. public:
  935. explicit JumpNullish(Operand condition, Label true_target, Label false_target)
  936. : Jump(Type::JumpNullish, move(true_target), move(false_target), sizeof(*this))
  937. , m_condition(condition)
  938. {
  939. }
  940. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  941. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  942. Operand condition() const { return m_condition; }
  943. private:
  944. Operand m_condition;
  945. };
  946. class JumpUndefined final : public Jump {
  947. public:
  948. explicit JumpUndefined(Operand condition, Label true_target, Label false_target)
  949. : Jump(Type::JumpUndefined, move(true_target), move(false_target), sizeof(*this))
  950. , m_condition(condition)
  951. {
  952. }
  953. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  954. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  955. Operand condition() const { return m_condition; }
  956. private:
  957. Operand m_condition;
  958. };
  959. enum class CallType {
  960. Call,
  961. Construct,
  962. DirectEval,
  963. };
  964. class Call final : public Instruction {
  965. public:
  966. Call(CallType type, Operand dst, Operand callee, Operand this_value, ReadonlySpan<Operand> arguments, Optional<StringTableIndex> expression_string = {}, Optional<Builtin> builtin = {})
  967. : Instruction(Type::Call, length_impl(arguments.size()))
  968. , m_dst(dst)
  969. , m_callee(callee)
  970. , m_this_value(this_value)
  971. , m_argument_count(arguments.size())
  972. , m_type(type)
  973. , m_expression_string(expression_string)
  974. , m_builtin(builtin)
  975. {
  976. for (size_t i = 0; i < arguments.size(); ++i)
  977. m_arguments[i] = arguments[i];
  978. }
  979. size_t length_impl(size_t argument_count) const
  980. {
  981. return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * argument_count);
  982. }
  983. CallType call_type() const { return m_type; }
  984. Operand dst() const { return m_dst; }
  985. Operand callee() const { return m_callee; }
  986. Operand this_value() const { return m_this_value; }
  987. Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
  988. u32 argument_count() const { return m_argument_count; }
  989. Optional<Builtin> const& builtin() const { return m_builtin; }
  990. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  991. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  992. private:
  993. Operand m_dst;
  994. Operand m_callee;
  995. Operand m_this_value;
  996. u32 m_argument_count { 0 };
  997. CallType m_type;
  998. Optional<StringTableIndex> m_expression_string;
  999. Optional<Builtin> m_builtin;
  1000. Operand m_arguments[];
  1001. };
  1002. class CallWithArgumentArray final : public Instruction {
  1003. public:
  1004. CallWithArgumentArray(CallType type, Operand dst, Operand callee, Operand this_value, Operand arguments, Optional<StringTableIndex> expression_string = {})
  1005. : Instruction(Type::CallWithArgumentArray, sizeof(*this))
  1006. , m_dst(dst)
  1007. , m_callee(callee)
  1008. , m_this_value(this_value)
  1009. , m_arguments(arguments)
  1010. , m_type(type)
  1011. , m_expression_string(expression_string)
  1012. {
  1013. }
  1014. Operand dst() const { return m_dst; }
  1015. CallType call_type() const { return m_type; }
  1016. Operand callee() const { return m_callee; }
  1017. Operand this_value() const { return m_this_value; }
  1018. Operand arguments() const { return m_arguments; }
  1019. Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
  1020. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1021. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1022. private:
  1023. Operand m_dst;
  1024. Operand m_callee;
  1025. Operand m_this_value;
  1026. Operand m_arguments;
  1027. CallType m_type;
  1028. Optional<StringTableIndex> m_expression_string;
  1029. };
  1030. class SuperCallWithArgumentArray : public Instruction {
  1031. public:
  1032. explicit SuperCallWithArgumentArray(Operand dst, Operand arguments, bool is_synthetic)
  1033. : Instruction(Type::SuperCallWithArgumentArray, sizeof(*this))
  1034. , m_dst(dst)
  1035. , m_arguments(arguments)
  1036. , m_is_synthetic(is_synthetic)
  1037. {
  1038. }
  1039. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1040. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1041. Operand dst() const { return m_dst; }
  1042. Operand arguments() const { return m_arguments; }
  1043. bool is_synthetic() const { return m_is_synthetic; }
  1044. private:
  1045. Operand m_dst;
  1046. Operand m_arguments;
  1047. bool m_is_synthetic;
  1048. };
  1049. class NewClass final : public Instruction {
  1050. public:
  1051. explicit NewClass(Operand dst, Optional<Operand> super_class, ClassExpression const& class_expression, Optional<IdentifierTableIndex> lhs_name)
  1052. : Instruction(Type::NewClass, sizeof(*this))
  1053. , m_dst(dst)
  1054. , m_super_class(super_class)
  1055. , m_class_expression(class_expression)
  1056. , m_lhs_name(lhs_name)
  1057. {
  1058. }
  1059. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1060. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1061. Operand dst() const { return m_dst; }
  1062. Optional<Operand> const& super_class() const { return m_super_class; }
  1063. ClassExpression const& class_expression() const { return m_class_expression; }
  1064. Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
  1065. private:
  1066. Operand m_dst;
  1067. Optional<Operand> m_super_class;
  1068. ClassExpression const& m_class_expression;
  1069. Optional<IdentifierTableIndex> m_lhs_name;
  1070. };
  1071. class NewFunction final : public Instruction {
  1072. public:
  1073. explicit NewFunction(Operand dst, FunctionExpression const& function_node, Optional<IdentifierTableIndex> lhs_name, Optional<Operand> home_object = {})
  1074. : Instruction(Type::NewFunction, sizeof(*this))
  1075. , m_dst(dst)
  1076. , m_function_node(function_node)
  1077. , m_lhs_name(lhs_name)
  1078. , m_home_object(move(home_object))
  1079. {
  1080. }
  1081. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1082. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1083. Operand dst() const { return m_dst; }
  1084. FunctionExpression const& function_node() const { return m_function_node; }
  1085. Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
  1086. Optional<Operand> const& home_object() const { return m_home_object; }
  1087. private:
  1088. Operand m_dst;
  1089. FunctionExpression const& m_function_node;
  1090. Optional<IdentifierTableIndex> m_lhs_name;
  1091. Optional<Operand> m_home_object;
  1092. };
  1093. class BlockDeclarationInstantiation final : public Instruction {
  1094. public:
  1095. explicit BlockDeclarationInstantiation(ScopeNode const& scope_node)
  1096. : Instruction(Type::BlockDeclarationInstantiation, sizeof(*this))
  1097. , m_scope_node(scope_node)
  1098. {
  1099. }
  1100. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1101. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1102. ScopeNode const& scope_node() const { return m_scope_node; }
  1103. private:
  1104. ScopeNode const& m_scope_node;
  1105. };
  1106. class Return final : public Instruction {
  1107. public:
  1108. constexpr static bool IsTerminator = true;
  1109. explicit Return(Optional<Operand> value = {})
  1110. : Instruction(Type::Return, sizeof(*this))
  1111. , m_value(value)
  1112. {
  1113. }
  1114. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1115. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1116. Optional<Operand> const& value() const { return m_value; }
  1117. private:
  1118. Optional<Operand> m_value;
  1119. };
  1120. class Increment final : public Instruction {
  1121. public:
  1122. explicit Increment(Operand dst)
  1123. : Instruction(Type::Increment, sizeof(*this))
  1124. , m_dst(dst)
  1125. {
  1126. }
  1127. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1128. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1129. Operand dst() const { return m_dst; }
  1130. private:
  1131. Operand m_dst;
  1132. };
  1133. class PostfixIncrement final : public Instruction {
  1134. public:
  1135. explicit PostfixIncrement(Operand dst, Operand src)
  1136. : Instruction(Type::PostfixIncrement, sizeof(*this))
  1137. , m_dst(dst)
  1138. , m_src(src)
  1139. {
  1140. }
  1141. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1142. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1143. Operand dst() const { return m_dst; }
  1144. Operand src() const { return m_src; }
  1145. private:
  1146. Operand m_dst;
  1147. Operand m_src;
  1148. };
  1149. class Decrement final : public Instruction {
  1150. public:
  1151. explicit Decrement(Operand dst)
  1152. : Instruction(Type::Decrement, sizeof(*this))
  1153. , m_dst(dst)
  1154. {
  1155. }
  1156. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1157. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1158. Operand dst() const { return m_dst; }
  1159. private:
  1160. Operand m_dst;
  1161. };
  1162. class PostfixDecrement final : public Instruction {
  1163. public:
  1164. explicit PostfixDecrement(Operand dst, Operand src)
  1165. : Instruction(Type::PostfixDecrement, sizeof(*this))
  1166. , m_dst(dst)
  1167. , m_src(src)
  1168. {
  1169. }
  1170. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1171. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1172. Operand dst() const { return m_dst; }
  1173. Operand src() const { return m_src; }
  1174. private:
  1175. Operand m_dst;
  1176. Operand m_src;
  1177. };
  1178. class Throw final : public Instruction {
  1179. public:
  1180. constexpr static bool IsTerminator = true;
  1181. explicit Throw(Operand src)
  1182. : Instruction(Type::Throw, sizeof(*this))
  1183. , m_src(src)
  1184. {
  1185. }
  1186. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1187. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1188. Operand src() const { return m_src; }
  1189. private:
  1190. Operand m_src;
  1191. };
  1192. class ThrowIfNotObject final : public Instruction {
  1193. public:
  1194. ThrowIfNotObject(Operand src)
  1195. : Instruction(Type::ThrowIfNotObject, sizeof(*this))
  1196. , m_src(src)
  1197. {
  1198. }
  1199. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1200. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1201. Operand src() const { return m_src; }
  1202. private:
  1203. Operand m_src;
  1204. };
  1205. class ThrowIfNullish final : public Instruction {
  1206. public:
  1207. explicit ThrowIfNullish(Operand src)
  1208. : Instruction(Type::ThrowIfNullish, sizeof(*this))
  1209. , m_src(src)
  1210. {
  1211. }
  1212. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1213. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1214. Operand src() const { return m_src; }
  1215. private:
  1216. Operand m_src;
  1217. };
  1218. class ThrowIfTDZ final : public Instruction {
  1219. public:
  1220. explicit ThrowIfTDZ(Operand src)
  1221. : Instruction(Type::ThrowIfTDZ, sizeof(*this))
  1222. , m_src(src)
  1223. {
  1224. }
  1225. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1226. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1227. Operand src() const { return m_src; }
  1228. private:
  1229. Operand m_src;
  1230. };
  1231. class EnterUnwindContext final : public Instruction {
  1232. public:
  1233. constexpr static bool IsTerminator = true;
  1234. EnterUnwindContext(Label entry_point)
  1235. : Instruction(Type::EnterUnwindContext, sizeof(*this))
  1236. , m_entry_point(move(entry_point))
  1237. {
  1238. }
  1239. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1240. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1241. auto& entry_point() const { return m_entry_point; }
  1242. private:
  1243. Label m_entry_point;
  1244. };
  1245. class ScheduleJump final : public Instruction {
  1246. public:
  1247. // Note: We use this instruction to tell the next `finally` block to
  1248. // continue execution with a specific break/continue target;
  1249. // FIXME: We currently don't clear the interpreter internal flag, when we change
  1250. // the control-flow (`break`, `continue`) in a finally-block,
  1251. // FIXME: .NET on x86_64 uses a call to the finally instead, which could make this
  1252. // easier, at the cost of making control-flow changes (`break`, `continue`, `return`)
  1253. // in the finally-block more difficult, but as stated above, those
  1254. // aren't handled 100% correctly at the moment anyway
  1255. // It might be worth investigating a similar mechanism
  1256. constexpr static bool IsTerminator = true;
  1257. ScheduleJump(Label target)
  1258. : Instruction(Type::ScheduleJump, sizeof(*this))
  1259. , m_target(target)
  1260. {
  1261. }
  1262. Label target() const { return m_target; }
  1263. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1264. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1265. private:
  1266. Label m_target;
  1267. };
  1268. class LeaveLexicalEnvironment final : public Instruction {
  1269. public:
  1270. LeaveLexicalEnvironment()
  1271. : Instruction(Type::LeaveLexicalEnvironment, sizeof(*this))
  1272. {
  1273. }
  1274. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1275. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1276. };
  1277. class LeaveUnwindContext final : public Instruction {
  1278. public:
  1279. LeaveUnwindContext()
  1280. : Instruction(Type::LeaveUnwindContext, sizeof(*this))
  1281. {
  1282. }
  1283. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1284. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1285. };
  1286. class ContinuePendingUnwind final : public Instruction {
  1287. public:
  1288. constexpr static bool IsTerminator = true;
  1289. explicit ContinuePendingUnwind(Label resume_target)
  1290. : Instruction(Type::ContinuePendingUnwind, sizeof(*this))
  1291. , m_resume_target(resume_target)
  1292. {
  1293. }
  1294. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1295. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1296. auto& resume_target() const { return m_resume_target; }
  1297. private:
  1298. Label m_resume_target;
  1299. };
  1300. class Yield final : public Instruction {
  1301. public:
  1302. constexpr static bool IsTerminator = true;
  1303. explicit Yield(Label continuation_label, Operand value)
  1304. : Instruction(Type::Yield, sizeof(*this))
  1305. , m_continuation_label(continuation_label)
  1306. , m_value(value)
  1307. {
  1308. }
  1309. explicit Yield(nullptr_t, Operand value)
  1310. : Instruction(Type::Yield, sizeof(*this))
  1311. , m_value(value)
  1312. {
  1313. }
  1314. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1315. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1316. auto& continuation() const { return m_continuation_label; }
  1317. Operand value() const { return m_value; }
  1318. private:
  1319. Optional<Label> m_continuation_label;
  1320. Operand m_value;
  1321. };
  1322. class Await final : public Instruction {
  1323. public:
  1324. constexpr static bool IsTerminator = true;
  1325. explicit Await(Label continuation_label, Operand argument)
  1326. : Instruction(Type::Await, sizeof(*this))
  1327. , m_continuation_label(continuation_label)
  1328. , m_argument(argument)
  1329. {
  1330. }
  1331. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1332. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1333. auto& continuation() const { return m_continuation_label; }
  1334. Operand argument() const { return m_argument; }
  1335. private:
  1336. Label m_continuation_label;
  1337. Operand m_argument;
  1338. };
  1339. class GetIterator final : public Instruction {
  1340. public:
  1341. GetIterator(Operand dst, Operand iterable, IteratorHint hint = IteratorHint::Sync)
  1342. : Instruction(Type::GetIterator, sizeof(*this))
  1343. , m_dst(dst)
  1344. , m_iterable(iterable)
  1345. , m_hint(hint)
  1346. {
  1347. }
  1348. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1349. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1350. Operand dst() const { return m_dst; }
  1351. Operand iterable() const { return m_iterable; }
  1352. IteratorHint hint() const { return m_hint; }
  1353. private:
  1354. Operand m_dst;
  1355. Operand m_iterable;
  1356. IteratorHint m_hint { IteratorHint::Sync };
  1357. };
  1358. class GetObjectFromIteratorRecord final : public Instruction {
  1359. public:
  1360. GetObjectFromIteratorRecord(Operand object, Operand iterator_record)
  1361. : Instruction(Type::GetObjectFromIteratorRecord, sizeof(*this))
  1362. , m_object(object)
  1363. , m_iterator_record(iterator_record)
  1364. {
  1365. }
  1366. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1367. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1368. Operand object() const { return m_object; }
  1369. Operand iterator_record() const { return m_iterator_record; }
  1370. private:
  1371. Operand m_object;
  1372. Operand m_iterator_record;
  1373. };
  1374. class GetNextMethodFromIteratorRecord final : public Instruction {
  1375. public:
  1376. GetNextMethodFromIteratorRecord(Operand next_method, Operand iterator_record)
  1377. : Instruction(Type::GetNextMethodFromIteratorRecord, sizeof(*this))
  1378. , m_next_method(next_method)
  1379. , m_iterator_record(iterator_record)
  1380. {
  1381. }
  1382. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1383. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1384. Operand next_method() const { return m_next_method; }
  1385. Operand iterator_record() const { return m_iterator_record; }
  1386. private:
  1387. Operand m_next_method;
  1388. Operand m_iterator_record;
  1389. };
  1390. class GetMethod final : public Instruction {
  1391. public:
  1392. GetMethod(Operand dst, Operand object, IdentifierTableIndex property)
  1393. : Instruction(Type::GetMethod, sizeof(*this))
  1394. , m_dst(dst)
  1395. , m_object(object)
  1396. , m_property(property)
  1397. {
  1398. }
  1399. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1400. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1401. Operand dst() const { return m_dst; }
  1402. Operand object() const { return m_object; }
  1403. IdentifierTableIndex property() const { return m_property; }
  1404. private:
  1405. Operand m_dst;
  1406. Operand m_object;
  1407. IdentifierTableIndex m_property;
  1408. };
  1409. class GetObjectPropertyIterator final : public Instruction {
  1410. public:
  1411. GetObjectPropertyIterator(Operand dst, Operand object)
  1412. : Instruction(Type::GetObjectPropertyIterator, sizeof(*this))
  1413. , m_dst(dst)
  1414. , m_object(object)
  1415. {
  1416. }
  1417. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1418. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1419. Operand dst() const { return m_dst; }
  1420. Operand object() const { return m_object; }
  1421. private:
  1422. Operand m_dst;
  1423. Operand m_object;
  1424. };
  1425. class IteratorClose final : public Instruction {
  1426. public:
  1427. IteratorClose(Operand iterator_record, Completion::Type completion_type, Optional<Value> completion_value)
  1428. : Instruction(Type::IteratorClose, sizeof(*this))
  1429. , m_iterator_record(iterator_record)
  1430. , m_completion_type(completion_type)
  1431. , m_completion_value(completion_value)
  1432. {
  1433. }
  1434. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1435. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1436. Operand iterator_record() const { return m_iterator_record; }
  1437. Completion::Type completion_type() const { return m_completion_type; }
  1438. Optional<Value> const& completion_value() const { return m_completion_value; }
  1439. private:
  1440. Operand m_iterator_record;
  1441. Completion::Type m_completion_type { Completion::Type::Normal };
  1442. Optional<Value> m_completion_value;
  1443. };
  1444. class AsyncIteratorClose final : public Instruction {
  1445. public:
  1446. AsyncIteratorClose(Operand iterator_record, Completion::Type completion_type, Optional<Value> completion_value)
  1447. : Instruction(Type::AsyncIteratorClose, sizeof(*this))
  1448. , m_iterator_record(iterator_record)
  1449. , m_completion_type(completion_type)
  1450. , m_completion_value(completion_value)
  1451. {
  1452. }
  1453. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1454. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1455. Operand iterator_record() const { return m_iterator_record; }
  1456. Completion::Type completion_type() const { return m_completion_type; }
  1457. Optional<Value> const& completion_value() const { return m_completion_value; }
  1458. private:
  1459. Operand m_iterator_record;
  1460. Completion::Type m_completion_type { Completion::Type::Normal };
  1461. Optional<Value> m_completion_value;
  1462. };
  1463. class IteratorNext final : public Instruction {
  1464. public:
  1465. IteratorNext(Operand dst, Operand iterator_record)
  1466. : Instruction(Type::IteratorNext, sizeof(*this))
  1467. , m_dst(dst)
  1468. , m_iterator_record(iterator_record)
  1469. {
  1470. }
  1471. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1472. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1473. Operand dst() const { return m_dst; }
  1474. Operand iterator_record() const { return m_iterator_record; }
  1475. private:
  1476. Operand m_dst;
  1477. Operand m_iterator_record;
  1478. };
  1479. class ResolveThisBinding final : public Instruction {
  1480. public:
  1481. explicit ResolveThisBinding(Operand dst)
  1482. : Instruction(Type::ResolveThisBinding, sizeof(*this))
  1483. , m_dst(dst)
  1484. {
  1485. }
  1486. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1487. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1488. Operand dst() const { return m_dst; }
  1489. private:
  1490. Operand m_dst;
  1491. };
  1492. class ResolveSuperBase final : public Instruction {
  1493. public:
  1494. explicit ResolveSuperBase(Operand dst)
  1495. : Instruction(Type::ResolveSuperBase, sizeof(*this))
  1496. , m_dst(dst)
  1497. {
  1498. }
  1499. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1500. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1501. Operand dst() const { return m_dst; }
  1502. private:
  1503. Operand m_dst;
  1504. };
  1505. class GetNewTarget final : public Instruction {
  1506. public:
  1507. explicit GetNewTarget(Operand dst)
  1508. : Instruction(Type::GetNewTarget, sizeof(*this))
  1509. , m_dst(dst)
  1510. {
  1511. }
  1512. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1513. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1514. Operand dst() const { return m_dst; }
  1515. private:
  1516. Operand m_dst;
  1517. };
  1518. class GetImportMeta final : public Instruction {
  1519. public:
  1520. explicit GetImportMeta(Operand dst)
  1521. : Instruction(Type::GetImportMeta, sizeof(*this))
  1522. , m_dst(dst)
  1523. {
  1524. }
  1525. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1526. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1527. Operand dst() const { return m_dst; }
  1528. private:
  1529. Operand m_dst;
  1530. };
  1531. class TypeofVariable final : public Instruction {
  1532. public:
  1533. TypeofVariable(Operand dst, IdentifierTableIndex identifier)
  1534. : Instruction(Type::TypeofVariable, sizeof(*this))
  1535. , m_dst(dst)
  1536. , m_identifier(identifier)
  1537. {
  1538. }
  1539. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1540. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1541. Operand dst() const { return m_dst; }
  1542. IdentifierTableIndex identifier() const { return m_identifier; }
  1543. private:
  1544. Operand m_dst;
  1545. IdentifierTableIndex m_identifier;
  1546. };
  1547. class End final : public Instruction {
  1548. public:
  1549. constexpr static bool IsTerminator = true;
  1550. explicit End(Operand value)
  1551. : Instruction(Type::End, sizeof(*this))
  1552. , m_value(value)
  1553. {
  1554. }
  1555. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1556. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1557. Operand value() const { return m_value; }
  1558. private:
  1559. Operand m_value;
  1560. };
  1561. class Dump final : public Instruction {
  1562. public:
  1563. explicit Dump(StringView text, Operand value)
  1564. : Instruction(Type::Dump, sizeof(*this))
  1565. , m_text(text)
  1566. , m_value(value)
  1567. {
  1568. }
  1569. ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
  1570. ByteString to_byte_string_impl(Bytecode::Executable const&) const;
  1571. private:
  1572. StringView m_text;
  1573. Operand m_value;
  1574. };
  1575. }
  1576. namespace JS::Bytecode {
  1577. ALWAYS_INLINE ThrowCompletionOr<void> Instruction::execute(Bytecode::Interpreter& interpreter) const
  1578. {
  1579. #define __BYTECODE_OP(op) \
  1580. case Instruction::Type::op: \
  1581. return static_cast<Bytecode::Op::op const&>(*this).execute_impl(interpreter);
  1582. switch (type()) {
  1583. ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
  1584. default:
  1585. VERIFY_NOT_REACHED();
  1586. }
  1587. #undef __BYTECODE_OP
  1588. }
  1589. }