Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Issue 60035: A simple fix of issue http://code.google.com/p/chromium/issues/detail?id=3285... (Closed)

Created:
11 years, 8 months ago by Feng Qian
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

A simple fix of issue http://code.google.com/p/chromium/issues/detail?id=3285 NPN_Construct allows a NPObject to be called as a construct. For example, the test case var s = new app.Packages.java.lang.Integer(5); app.Packages.java.lang.Integer is a NPObject, and it implements NPN_Construct. This fix allows a JSObject created by an API function be called as a construct if it can be called as a function. This is done by generating the same code for var s = new app.Packages.java.lang.Integer(5); as var s = app.Packages.java.lang.Integer(5); and the caller handles both case correctly. A more sophiscated fix is to one extra JSConstructCall frame and allow CallAsConstructor in Builtin::HandleApiCallAsFunction. This change itself shouldn't affect the semantic of normal case such as: var a = {}; var s = new a(); A TypeError exception will be thrown in CALL_NON_FUNCTION (runtime.js). Another part of fix is in the binding code, V8NPObject, which makes NPN_InvokeDefault or NPN_Construct call depending on which function is available.

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -12 lines) Patch
M src/builtins-ia32.cc View 3 chunks +17 lines, -7 lines 2 comments Download
M test/cctest/test-api.cc View 1 chunk +0 lines, -5 lines 2 comments Download

Messages

Total messages: 4 (0 generated)
Feng Qian
Mads, Can you take a look this fix?
11 years, 7 months ago (2009-04-27 22:17:40 UTC) #1
Mads Ager (chromium)
LGTM This is a hack and we should revisit it, but as a temporary solution ...
11 years, 7 months ago (2009-04-28 10:50:15 UTC) #2
Kevin Millikin (Chromium)
http://codereview.chromium.org/60035/diff/1/3 File src/builtins-ia32.cc (right): http://codereview.chromium.org/60035/diff/1/3#newcode309 Line 309: __ xor_(ebx, Operand(ebx)); Setting the expected number of ...
11 years, 7 months ago (2009-04-28 11:48:43 UTC) #3
Feng Qian
11 years, 7 months ago (2009-04-30 23:26:15 UTC) #4
I lost my client already, reconstructing the patch.

http://codereview.chromium.org/60035/diff/1/2
File test/cctest/test-api.cc (left):

http://codereview.chromium.org/60035/diff/1/2#oldcode4561
Line 4561: // Try something that will cause an exception: Call the object as a
This needs to be tested by a layout test. V8 treats construct call and function
call as the same if an object can be called as the function.

Like I said in TODO: V8 needs to pass different flags to the callback function,
or make two different API for callAsFunction and callAsConstruct.

On 2009/04/28 10:50:15, Mads Ager wrote:
> Please add a test case for the intended behavior of construct calls.

Powered by Google App Engine
This is Rietveld 408576698