Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
change num_this_properties in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuzilin committed Nov 3, 2023
1 parent 338c8d4 commit 67fb4d5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions es/impl/construct-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Handle<JSObject> Construct__Function(
obj.val()->SetPrototype(ObjectProto::Instance());
}
Handle<JSValue> result = Call(e, O, obj, arguments); // 8
// get more accurate num_decls from runtime.
func_ast->body()->SetNumThisProperties(obj.val()->named_properties()->hashmap().val()->occupancy());
if (unlikely(!e.val()->IsOk())) return Handle<JSValue>();
if (result.val()->IsObject()) // 9
return static_cast<Handle<JSObject>>(result);
Expand Down
1 change: 1 addition & 0 deletions es/parser/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ class ProgramOrFunctionBody : public AST {
size_t num_decls() { return func_decls_.size() + var_decls_.size(); }
bool use_arguments() { return use_arguments_; }
size_t num_this_properties() { return num_this_properties_; }
void SetNumThisProperties(size_t num) { num_this_properties_ = num; }

private:
bool strict_;
Expand Down
2 changes: 1 addition & 1 deletion es/utils/hashmap_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class HashMapV2 : public JSValue {

private:
static Handle<HashMapV2> Resize(Handle<HashMapV2> map) {
Handle<HashMapV2> new_map = HashMapV2::New(2 * map.val()->capacity());
Handle<HashMapV2> new_map = HashMapV2::New(map.val()->capacity());

uint32_t n = map.val()->occupancy();
new_map.val()->set_occupancy(n);
Expand Down

0 comments on commit 67fb4d5

Please sign in to comment.