Generator.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/AST.h>
  7. #include <LibJS/Bytecode/BasicBlock.h>
  8. #include <LibJS/Bytecode/Generator.h>
  9. #include <LibJS/Bytecode/Instruction.h>
  10. #include <LibJS/Bytecode/Op.h>
  11. #include <LibJS/Bytecode/Register.h>
  12. namespace JS::Bytecode {
  13. Generator::Generator()
  14. : m_string_table(make<StringTable>())
  15. , m_identifier_table(make<IdentifierTable>())
  16. {
  17. }
  18. CodeGenerationErrorOr<NonnullOwnPtr<Executable>> Generator::generate(ASTNode const& node, FunctionKind enclosing_function_kind)
  19. {
  20. Generator generator;
  21. generator.switch_to_basic_block(generator.make_block());
  22. generator.m_enclosing_function_kind = enclosing_function_kind;
  23. if (generator.is_in_generator_or_async_function()) {
  24. // Immediately yield with no value.
  25. auto& start_block = generator.make_block();
  26. generator.emit<Bytecode::Op::Yield>(Label { start_block });
  27. generator.switch_to_basic_block(start_block);
  28. // NOTE: This doesn't have to handle received throw/return completions, as GeneratorObject::resume_abrupt
  29. // will not enter the generator from the SuspendedStart state and immediately completes the generator.
  30. }
  31. TRY(node.generate_bytecode(generator));
  32. if (generator.is_in_generator_or_async_function()) {
  33. // Terminate all unterminated blocks with yield return
  34. for (auto& block : generator.m_root_basic_blocks) {
  35. if (block->is_terminated())
  36. continue;
  37. generator.switch_to_basic_block(*block);
  38. generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
  39. generator.emit<Bytecode::Op::Yield>(nullptr);
  40. }
  41. }
  42. bool is_strict_mode = false;
  43. if (is<Program>(node))
  44. is_strict_mode = static_cast<Program const&>(node).is_strict_mode();
  45. else if (is<FunctionBody>(node))
  46. is_strict_mode = static_cast<FunctionBody const&>(node).in_strict_mode();
  47. else if (is<FunctionDeclaration>(node))
  48. is_strict_mode = static_cast<FunctionDeclaration const&>(node).is_strict_mode();
  49. else if (is<FunctionExpression>(node))
  50. is_strict_mode = static_cast<FunctionExpression const&>(node).is_strict_mode();
  51. Vector<PropertyLookupCache> property_lookup_caches;
  52. property_lookup_caches.resize(generator.m_next_property_lookup_cache);
  53. Vector<GlobalVariableCache> global_variable_caches;
  54. global_variable_caches.resize(generator.m_next_global_variable_cache);
  55. return adopt_own(*new Executable {
  56. .name = {},
  57. .property_lookup_caches = move(property_lookup_caches),
  58. .global_variable_caches = move(global_variable_caches),
  59. .basic_blocks = move(generator.m_root_basic_blocks),
  60. .string_table = move(generator.m_string_table),
  61. .identifier_table = move(generator.m_identifier_table),
  62. .number_of_registers = generator.m_next_register,
  63. .is_strict_mode = is_strict_mode,
  64. });
  65. }
  66. void Generator::grow(size_t additional_size)
  67. {
  68. VERIFY(m_current_basic_block);
  69. m_current_basic_block->grow(additional_size);
  70. }
  71. void* Generator::next_slot()
  72. {
  73. VERIFY(m_current_basic_block);
  74. return m_current_basic_block->next_slot();
  75. }
  76. Register Generator::allocate_register()
  77. {
  78. VERIFY(m_next_register != NumericLimits<u32>::max());
  79. return Register { m_next_register++ };
  80. }
  81. Label Generator::nearest_continuable_scope() const
  82. {
  83. return m_continuable_scopes.last().bytecode_target;
  84. }
  85. void Generator::block_declaration_instantiation(ScopeNode const& scope_node)
  86. {
  87. start_boundary(BlockBoundaryType::LeaveLexicalEnvironment);
  88. emit<Bytecode::Op::BlockDeclarationInstantiation>(scope_node);
  89. }
  90. void Generator::begin_variable_scope()
  91. {
  92. start_boundary(BlockBoundaryType::LeaveLexicalEnvironment);
  93. emit<Bytecode::Op::CreateLexicalEnvironment>();
  94. }
  95. void Generator::end_variable_scope()
  96. {
  97. end_boundary(BlockBoundaryType::LeaveLexicalEnvironment);
  98. if (!m_current_basic_block->is_terminated()) {
  99. emit<Bytecode::Op::LeaveLexicalEnvironment>();
  100. }
  101. }
  102. void Generator::begin_continuable_scope(Label continue_target, Vector<DeprecatedFlyString> const& language_label_set)
  103. {
  104. m_continuable_scopes.append({ continue_target, language_label_set });
  105. start_boundary(BlockBoundaryType::Continue);
  106. }
  107. void Generator::end_continuable_scope()
  108. {
  109. m_continuable_scopes.take_last();
  110. end_boundary(BlockBoundaryType::Continue);
  111. }
  112. Label Generator::nearest_breakable_scope() const
  113. {
  114. return m_breakable_scopes.last().bytecode_target;
  115. }
  116. void Generator::begin_breakable_scope(Label breakable_target, Vector<DeprecatedFlyString> const& language_label_set)
  117. {
  118. m_breakable_scopes.append({ breakable_target, language_label_set });
  119. start_boundary(BlockBoundaryType::Break);
  120. }
  121. void Generator::end_breakable_scope()
  122. {
  123. m_breakable_scopes.take_last();
  124. end_boundary(BlockBoundaryType::Break);
  125. }
  126. CodeGenerationErrorOr<Generator::ReferenceRegisters> Generator::emit_super_reference(MemberExpression const& expression)
  127. {
  128. VERIFY(is<SuperExpression>(expression.object()));
  129. // https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
  130. // 1. Let env be GetThisEnvironment().
  131. // 2. Let actualThis be ? env.GetThisBinding().
  132. auto actual_this_register = allocate_register();
  133. emit<Bytecode::Op::ResolveThisBinding>();
  134. emit<Bytecode::Op::Store>(actual_this_register);
  135. Optional<Bytecode::Register> computed_property_value_register;
  136. if (expression.is_computed()) {
  137. // SuperProperty : super [ Expression ]
  138. // 3. Let propertyNameReference be ? Evaluation of Expression.
  139. // 4. Let propertyNameValue be ? GetValue(propertyNameReference).
  140. TRY(expression.property().generate_bytecode(*this));
  141. computed_property_value_register = allocate_register();
  142. emit<Bytecode::Op::Store>(*computed_property_value_register);
  143. }
  144. // 5/7. Return ? MakeSuperPropertyReference(actualThis, propertyKey, strict).
  145. // https://tc39.es/ecma262/#sec-makesuperpropertyreference
  146. // 1. Let env be GetThisEnvironment().
  147. // 2. Assert: env.HasSuperBinding() is true.
  148. // 3. Let baseValue be ? env.GetSuperBase().
  149. auto super_base_register = allocate_register();
  150. emit<Bytecode::Op::ResolveSuperBase>();
  151. emit<Bytecode::Op::Store>(super_base_register);
  152. // 4. Return the Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }.
  153. return ReferenceRegisters {
  154. .base = super_base_register,
  155. .referenced_name = move(computed_property_value_register),
  156. .this_value = actual_this_register,
  157. };
  158. }
  159. CodeGenerationErrorOr<void> Generator::emit_load_from_reference(JS::ASTNode const& node)
  160. {
  161. if (is<Identifier>(node)) {
  162. auto& identifier = static_cast<Identifier const&>(node);
  163. TRY(identifier.generate_bytecode(*this));
  164. return {};
  165. }
  166. if (is<MemberExpression>(node)) {
  167. auto& expression = static_cast<MemberExpression const&>(node);
  168. // https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
  169. if (is<SuperExpression>(expression.object())) {
  170. auto super_reference = TRY(emit_super_reference(expression));
  171. if (super_reference.referenced_name.has_value()) {
  172. // 5. Let propertyKey be ? ToPropertyKey(propertyNameValue).
  173. // FIXME: This does ToPropertyKey out of order, which is observable by Symbol.toPrimitive!
  174. emit<Bytecode::Op::Load>(*super_reference.referenced_name);
  175. emit<Bytecode::Op::GetByValueWithThis>(super_reference.base, super_reference.this_value);
  176. } else {
  177. // 3. Let propertyKey be StringValue of IdentifierName.
  178. auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
  179. emit_get_by_id_with_this(identifier_table_ref, super_reference.this_value);
  180. }
  181. } else {
  182. TRY(expression.object().generate_bytecode(*this));
  183. if (expression.is_computed()) {
  184. auto object_reg = allocate_register();
  185. emit<Bytecode::Op::Store>(object_reg);
  186. TRY(expression.property().generate_bytecode(*this));
  187. emit<Bytecode::Op::GetByValue>(object_reg);
  188. } else if (expression.property().is_identifier()) {
  189. auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
  190. emit_get_by_id(identifier_table_ref);
  191. } else if (expression.property().is_private_identifier()) {
  192. auto identifier_table_ref = intern_identifier(verify_cast<PrivateIdentifier>(expression.property()).string());
  193. emit<Bytecode::Op::GetPrivateById>(identifier_table_ref);
  194. } else {
  195. return CodeGenerationError {
  196. &expression,
  197. "Unimplemented non-computed member expression"sv
  198. };
  199. }
  200. }
  201. return {};
  202. }
  203. VERIFY_NOT_REACHED();
  204. }
  205. CodeGenerationErrorOr<void> Generator::emit_store_to_reference(JS::ASTNode const& node)
  206. {
  207. if (is<Identifier>(node)) {
  208. auto& identifier = static_cast<Identifier const&>(node);
  209. emit_set_variable(identifier);
  210. return {};
  211. }
  212. if (is<MemberExpression>(node)) {
  213. // NOTE: The value is in the accumulator, so we have to store that away first.
  214. auto value_reg = allocate_register();
  215. emit<Bytecode::Op::Store>(value_reg);
  216. auto& expression = static_cast<MemberExpression const&>(node);
  217. // https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
  218. if (is<SuperExpression>(expression.object())) {
  219. auto super_reference = TRY(emit_super_reference(expression));
  220. emit<Bytecode::Op::Load>(value_reg);
  221. // 4. Return the Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }.
  222. if (super_reference.referenced_name.has_value()) {
  223. // 5. Let propertyKey be ? ToPropertyKey(propertyNameValue).
  224. // FIXME: This does ToPropertyKey out of order, which is observable by Symbol.toPrimitive!
  225. emit<Bytecode::Op::PutByValueWithThis>(super_reference.base, *super_reference.referenced_name, super_reference.this_value);
  226. } else {
  227. // 3. Let propertyKey be StringValue of IdentifierName.
  228. auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
  229. emit<Bytecode::Op::PutByIdWithThis>(super_reference.base, super_reference.this_value, identifier_table_ref);
  230. }
  231. } else {
  232. TRY(expression.object().generate_bytecode(*this));
  233. auto object_reg = allocate_register();
  234. emit<Bytecode::Op::Store>(object_reg);
  235. if (expression.is_computed()) {
  236. TRY(expression.property().generate_bytecode(*this));
  237. auto property_reg = allocate_register();
  238. emit<Bytecode::Op::Store>(property_reg);
  239. emit<Bytecode::Op::Load>(value_reg);
  240. emit<Bytecode::Op::PutByValue>(object_reg, property_reg);
  241. } else if (expression.property().is_identifier()) {
  242. emit<Bytecode::Op::Load>(value_reg);
  243. auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
  244. emit<Bytecode::Op::PutById>(object_reg, identifier_table_ref);
  245. } else if (expression.property().is_private_identifier()) {
  246. emit<Bytecode::Op::Load>(value_reg);
  247. auto identifier_table_ref = intern_identifier(verify_cast<PrivateIdentifier>(expression.property()).string());
  248. emit<Bytecode::Op::PutPrivateById>(object_reg, identifier_table_ref);
  249. } else {
  250. return CodeGenerationError {
  251. &expression,
  252. "Unimplemented non-computed member expression"sv
  253. };
  254. }
  255. }
  256. return {};
  257. }
  258. return CodeGenerationError {
  259. &node,
  260. "Unimplemented/invalid node used a reference"sv
  261. };
  262. }
  263. CodeGenerationErrorOr<void> Generator::emit_delete_reference(JS::ASTNode const& node)
  264. {
  265. if (is<Identifier>(node)) {
  266. auto& identifier = static_cast<Identifier const&>(node);
  267. if (identifier.is_local())
  268. emit<Bytecode::Op::LoadImmediate>(Value(false));
  269. else
  270. emit<Bytecode::Op::DeleteVariable>(intern_identifier(identifier.string()));
  271. return {};
  272. }
  273. if (is<MemberExpression>(node)) {
  274. auto& expression = static_cast<MemberExpression const&>(node);
  275. // https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
  276. if (is<SuperExpression>(expression.object())) {
  277. auto super_reference = TRY(emit_super_reference(expression));
  278. if (super_reference.referenced_name.has_value()) {
  279. emit<Bytecode::Op::DeleteByValueWithThis>(super_reference.this_value, *super_reference.referenced_name);
  280. } else {
  281. auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
  282. emit<Bytecode::Op::DeleteByIdWithThis>(super_reference.this_value, identifier_table_ref);
  283. }
  284. return {};
  285. }
  286. TRY(expression.object().generate_bytecode(*this));
  287. if (expression.is_computed()) {
  288. auto object_reg = allocate_register();
  289. emit<Bytecode::Op::Store>(object_reg);
  290. TRY(expression.property().generate_bytecode(*this));
  291. emit<Bytecode::Op::DeleteByValue>(object_reg);
  292. } else if (expression.property().is_identifier()) {
  293. auto identifier_table_ref = intern_identifier(verify_cast<Identifier>(expression.property()).string());
  294. emit<Bytecode::Op::DeleteById>(identifier_table_ref);
  295. } else {
  296. // NOTE: Trying to delete a private field generates a SyntaxError in the parser.
  297. return CodeGenerationError {
  298. &expression,
  299. "Unimplemented non-computed member expression"sv
  300. };
  301. }
  302. return {};
  303. }
  304. // Though this will have no deletion effect, we still have to evaluate the node as it can have side effects.
  305. // For example: delete a(); delete ++c.b; etc.
  306. // 13.5.1.2 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-delete-operator-runtime-semantics-evaluation
  307. // 1. Let ref be the result of evaluating UnaryExpression.
  308. // 2. ReturnIfAbrupt(ref).
  309. TRY(node.generate_bytecode(*this));
  310. // 3. If ref is not a Reference Record, return true.
  311. emit<Bytecode::Op::LoadImmediate>(Value(true));
  312. // NOTE: The rest of the steps are handled by Delete{Variable,ByValue,Id}.
  313. return {};
  314. }
  315. void Generator::emit_set_variable(JS::Identifier const& identifier, Bytecode::Op::SetVariable::InitializationMode initialization_mode, Bytecode::Op::EnvironmentMode mode)
  316. {
  317. if (identifier.is_local()) {
  318. emit<Bytecode::Op::SetLocal>(identifier.local_variable_index());
  319. } else {
  320. emit<Bytecode::Op::SetVariable>(intern_identifier(identifier.string()), initialization_mode, mode);
  321. }
  322. }
  323. void Generator::generate_break()
  324. {
  325. bool last_was_finally = false;
  326. // FIXME: Reduce code duplication
  327. for (size_t i = m_boundaries.size(); i > 0; --i) {
  328. auto boundary = m_boundaries[i - 1];
  329. using enum BlockBoundaryType;
  330. switch (boundary) {
  331. case Break:
  332. emit<Op::Jump>().set_targets(nearest_breakable_scope(), {});
  333. return;
  334. case Unwind:
  335. if (!last_was_finally)
  336. emit<Bytecode::Op::LeaveUnwindContext>();
  337. last_was_finally = false;
  338. break;
  339. case LeaveLexicalEnvironment:
  340. emit<Bytecode::Op::LeaveLexicalEnvironment>();
  341. break;
  342. case Continue:
  343. break;
  344. case ReturnToFinally: {
  345. auto& block = make_block(DeprecatedString::formatted("{}.break", current_block().name()));
  346. emit<Op::ScheduleJump>(Label { block });
  347. switch_to_basic_block(block);
  348. last_was_finally = true;
  349. break;
  350. };
  351. }
  352. }
  353. VERIFY_NOT_REACHED();
  354. }
  355. void Generator::generate_break(DeprecatedFlyString const& break_label)
  356. {
  357. size_t current_boundary = m_boundaries.size();
  358. bool last_was_finally = false;
  359. for (auto const& breakable_scope : m_breakable_scopes.in_reverse()) {
  360. for (; current_boundary > 0; --current_boundary) {
  361. auto boundary = m_boundaries[current_boundary - 1];
  362. if (boundary == BlockBoundaryType::Unwind) {
  363. if (!last_was_finally)
  364. emit<Bytecode::Op::LeaveUnwindContext>();
  365. last_was_finally = false;
  366. } else if (boundary == BlockBoundaryType::LeaveLexicalEnvironment) {
  367. emit<Bytecode::Op::LeaveLexicalEnvironment>();
  368. } else if (boundary == BlockBoundaryType::ReturnToFinally) {
  369. auto& block = make_block(DeprecatedString::formatted("{}.break", current_block().name()));
  370. emit<Op::ScheduleJump>(Label { block });
  371. switch_to_basic_block(block);
  372. last_was_finally = true;
  373. } else if (boundary == BlockBoundaryType::Break) {
  374. // Make sure we don't process this boundary twice if the current breakable scope doesn't contain the target label.
  375. --current_boundary;
  376. break;
  377. }
  378. }
  379. if (breakable_scope.language_label_set.contains_slow(break_label)) {
  380. emit<Op::Jump>().set_targets(breakable_scope.bytecode_target, {});
  381. return;
  382. }
  383. }
  384. // We must have a breakable scope available that contains the label, as this should be enforced by the parser.
  385. VERIFY_NOT_REACHED();
  386. }
  387. void Generator::generate_continue()
  388. {
  389. bool last_was_finally = false;
  390. // FIXME: Reduce code duplication
  391. for (size_t i = m_boundaries.size(); i > 0; --i) {
  392. auto boundary = m_boundaries[i - 1];
  393. using enum BlockBoundaryType;
  394. switch (boundary) {
  395. case Continue:
  396. emit<Op::Jump>().set_targets(nearest_continuable_scope(), {});
  397. return;
  398. case Unwind:
  399. if (!last_was_finally)
  400. emit<Bytecode::Op::LeaveUnwindContext>();
  401. last_was_finally = false;
  402. break;
  403. case LeaveLexicalEnvironment:
  404. emit<Bytecode::Op::LeaveLexicalEnvironment>();
  405. break;
  406. case Break:
  407. break;
  408. case ReturnToFinally: {
  409. auto& block = make_block(DeprecatedString::formatted("{}.continue", current_block().name()));
  410. emit<Op::ScheduleJump>(Label { block });
  411. switch_to_basic_block(block);
  412. last_was_finally = true;
  413. break;
  414. };
  415. }
  416. }
  417. VERIFY_NOT_REACHED();
  418. }
  419. void Generator::generate_continue(DeprecatedFlyString const& continue_label)
  420. {
  421. size_t current_boundary = m_boundaries.size();
  422. bool last_was_finally = false;
  423. for (auto const& continuable_scope : m_continuable_scopes.in_reverse()) {
  424. for (; current_boundary > 0; --current_boundary) {
  425. auto boundary = m_boundaries[current_boundary - 1];
  426. if (boundary == BlockBoundaryType::Unwind) {
  427. if (!last_was_finally)
  428. emit<Bytecode::Op::LeaveUnwindContext>();
  429. last_was_finally = false;
  430. } else if (boundary == BlockBoundaryType::LeaveLexicalEnvironment) {
  431. emit<Bytecode::Op::LeaveLexicalEnvironment>();
  432. } else if (boundary == BlockBoundaryType::ReturnToFinally) {
  433. auto& block = make_block(DeprecatedString::formatted("{}.continue", current_block().name()));
  434. emit<Op::ScheduleJump>(Label { block });
  435. switch_to_basic_block(block);
  436. last_was_finally = true;
  437. } else if (boundary == BlockBoundaryType::Continue) {
  438. // Make sure we don't process this boundary twice if the current continuable scope doesn't contain the target label.
  439. --current_boundary;
  440. break;
  441. }
  442. }
  443. if (continuable_scope.language_label_set.contains_slow(continue_label)) {
  444. emit<Op::Jump>().set_targets(continuable_scope.bytecode_target, {});
  445. return;
  446. }
  447. }
  448. // We must have a continuable scope available that contains the label, as this should be enforced by the parser.
  449. VERIFY_NOT_REACHED();
  450. }
  451. void Generator::push_home_object(Register register_)
  452. {
  453. m_home_objects.append(register_);
  454. }
  455. void Generator::pop_home_object()
  456. {
  457. m_home_objects.take_last();
  458. }
  459. void Generator::emit_new_function(FunctionExpression const& function_node, Optional<IdentifierTableIndex> lhs_name)
  460. {
  461. if (m_home_objects.is_empty())
  462. emit<Op::NewFunction>(function_node, lhs_name);
  463. else
  464. emit<Op::NewFunction>(function_node, lhs_name, m_home_objects.last());
  465. }
  466. CodeGenerationErrorOr<void> Generator::emit_named_evaluation_if_anonymous_function(Expression const& expression, Optional<IdentifierTableIndex> lhs_name)
  467. {
  468. if (is<FunctionExpression>(expression)) {
  469. auto const& function_expression = static_cast<FunctionExpression const&>(expression);
  470. if (!function_expression.has_name()) {
  471. TRY(function_expression.generate_bytecode_with_lhs_name(*this, move(lhs_name)));
  472. return {};
  473. }
  474. }
  475. if (is<ClassExpression>(expression)) {
  476. auto const& class_expression = static_cast<ClassExpression const&>(expression);
  477. if (!class_expression.has_name()) {
  478. TRY(class_expression.generate_bytecode_with_lhs_name(*this, move(lhs_name)));
  479. return {};
  480. }
  481. }
  482. TRY(expression.generate_bytecode(*this));
  483. return {};
  484. }
  485. void Generator::emit_get_by_id(IdentifierTableIndex id)
  486. {
  487. emit<Op::GetById>(id, m_next_property_lookup_cache++);
  488. }
  489. void Generator::emit_get_by_id_with_this(IdentifierTableIndex id, Register this_reg)
  490. {
  491. emit<Op::GetByIdWithThis>(id, this_reg, m_next_property_lookup_cache++);
  492. }
  493. }