Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix this.memory(key, falsy) not working in JavaScriptAgent #1551

Merged
merged 2 commits into from
Jun 20, 2016

Conversation

knu
Copy link
Member

@knu knu commented Jun 16, 2016

@@ -114,12 +114,9 @@ def execute_js(js_function, incoming_events = [])
context["getOptions"] = lambda { |a, x| interpolated.to_json }
context["doLog"] = lambda { |a, x| log x }
context["doError"] = lambda { |a, x| error x }
context["getMemory"] = lambda do |a, x, y|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if how much more efficient it would be, but would it make sense to keep getMemory with one argument to not always pass the whole memory through the javascript bridge?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree, but there's currently no one-argument use for the function and this is meant to be a minimal fix. We can make further improvements later.

Copy link
Member Author

@knu knu Jun 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As handling of variable length arguments is awkward [*] in V8 (and JavaScript itself), I'd rather have a separate functions for getting the whole memory and an individual key value.

[*] Ruby's lambda has a stricter argument length check compared to proc, but V8::Context seems to adjust arguments on the caller side, which gives me a confused feeling.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, that's not really the scope of this PR.

I was wondering how that even works, so V8 has to check the arity of the lambda and fill the missing arguments with nil?

@dsander
Copy link
Collaborator

dsander commented Jun 17, 2016

Looks good to me 👍

@cantino
Copy link
Member

cantino commented Jun 18, 2016

LGTM too. Thanks @knu!

@knu knu merged commit 371bfa3 into master Jun 20, 2016
@knu knu deleted the jsagent_fix_memory branch September 9, 2017 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants