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

Issue 598072: Direct call C++ functions (Closed)

Created:
10 years, 10 months ago by SeRya
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

The idea is to 3 categories: 1) That never fail and must not iterate through the stack (and consequently must depend on memory allocation success). May be called without constructing an exit frame and don't need checks the return value. 2) That may fail but does not access the stack frame (consequently don't perform GC). In cace of memory allocation fault may be recalled after GC. Don't need an exit frame but need error handling and recovery code branch. 3) That nees iterate through the stack or be able to perform GC. Called through an exit frame. This CL adds funtions of the first category in ia32.

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 2

Patch Set 3 : '' #

Total comments: 44

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+517 lines, -126 lines) Patch
M src/full-codegen.h View 3 1 chunk +4 lines, -0 lines 0 comments Download
M src/ia32/codegen-ia32.cc View 1 2 3 13 chunks +14 lines, -15 lines 0 comments Download
M src/ia32/ic-ia32.cc View 3 8 chunks +15 lines, -9 lines 0 comments Download
M src/ia32/macro-assembler-ia32.h View 1 2 3 2 chunks +9 lines, -3 lines 0 comments Download
M src/ia32/macro-assembler-ia32.cc View 1 2 3 2 chunks +88 lines, -9 lines 2 comments Download
M src/ia32/stub-cache-ia32.cc View 3 5 chunks +5 lines, -5 lines 0 comments Download
M src/runtime.h View 1 2 3 2 chunks +11 lines, -0 lines 1 comment Download
M src/runtime.cc View 1 2 3 4 16 chunks +172 lines, -9 lines 0 comments Download
M src/x64/codegen-x64.cc View 3 11 chunks +12 lines, -16 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 3 19 chunks +48 lines, -22 lines 0 comments Download
M src/x64/ic-x64.cc View 3 8 chunks +15 lines, -9 lines 0 comments Download
M src/x64/macro-assembler-x64.h View 3 4 5 2 chunks +23 lines, -3 lines 0 comments Download
M src/x64/macro-assembler-x64.cc View 3 3 chunks +58 lines, -10 lines 0 comments Download
M src/x64/stub-cache-x64.cc View 3 6 chunks +7 lines, -7 lines 0 comments Download
M src/x64/virtual-frame-x64.cc View 3 2 chunks +36 lines, -9 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
SeRya
10 years, 10 months ago (2010-02-12 11:05:15 UTC) #1
Vitaly Repeshko
FYI. http://codereview.chromium.org/598072/diff/4001/5003 File src/ia32/macro-assembler-ia32.cc (right): http://codereview.chromium.org/598072/diff/4001/5003#newcode1155 src/ia32/macro-assembler-ia32.cc:1155: call(FUNCTION_ADDR(ExternalReference(f).address()), RelocInfo::RUNTIME_ENTRY); Some ABIs (notably mac: http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/LowLevelABI/000-Introduction/introduction.html) require ...
10 years, 10 months ago (2010-02-12 11:36:47 UTC) #2
Søren Thygesen Gjesse
http://codereview.chromium.org/598072/diff/4001/5003 File src/ia32/macro-assembler-ia32.cc (right): http://codereview.chromium.org/598072/diff/4001/5003#newcode1154 src/ia32/macro-assembler-ia32.cc:1154: // JS caller saved are: eax, ecx, edx, ebx, ...
10 years, 10 months ago (2010-02-12 12:32:24 UTC) #3
SeRya
- Added stack alignment. - Mode functions are called without CEntryStub. - Added x64 implementation ...
10 years, 10 months ago (2010-02-18 16:27:37 UTC) #4
Mads Ager (chromium)
Please cut this down to the minimal possible change. Do not attempt to handle three ...
10 years, 10 months ago (2010-02-19 10:49:57 UTC) #5
Søren Thygesen Gjesse
http://codereview.chromium.org/598072/diff/8001/8003 File src/ia32/macro-assembler-ia32.cc (right): http://codereview.chromium.org/598072/diff/8001/8003#newcode1168 src/ia32/macro-assembler-ia32.cc:1168: // ret addr (if tail call) I suggest encapsulating ...
10 years, 10 months ago (2010-02-19 12:13:29 UTC) #6
SeRya
http://codereview.chromium.org/598072/diff/8001/8009 File src/ia32/ic-ia32.cc (right): http://codereview.chromium.org/598072/diff/8001/8009#newcode628 src/ia32/ic-ia32.cc:628: IC_Utility(kKeyedLoadPropertyWithInterceptor)), 2, 1); On 2010/02/19 10:49:57, Mads Ager wrote: ...
10 years, 10 months ago (2010-02-19 18:11:38 UTC) #7
Søren Thygesen Gjesse
10 years, 10 months ago (2010-02-22 12:38:22 UTC) #8
We would like this to be split into smaller changes in these steps:

1. Changing TailCallRuntime to TailCallExternalReference can go in a separate
change

2. Add PrepareCallCFunction/CallCFunction to macro-assembler-ia32 and use it in
regexp-macro-assembler-ia32.cc

3. Direct call support on ia32 only and only enabled for one or two of the
hottest runtime functions suitable and make it just simply pass all arguments on
the stack (standard calling convention).

Don't use the SIGNATURE_XXX macros, instead add the calling convention to the
functions lists in runtime.h, e.g.

  F(GetProperty, 2, 1, EXIT_FRAME_CALL) \
  F(KeyedGetProperty, 2, 1, EXIT_FRAME_CALL) \
  ...

Then add a the list RUNTIME_FUNCTION_LIST_DIRECT_CALL:

#ifdef V8_TARGET_ARCH_IA32
#define RUNTIME_FUNCTION_LIST_DIRECT_CALL(F) \
  F(XXX, 2, 1, DIRECT_CALL)
#endif

#ifdef V8_TARGET_ARCH_X64
#define RUNTIME_FUNCTION_LIST_DIRECT_CALL(F) \
  F(XXX, 2, 1, EXIT_FRAME_CALL)
#endif

#ifdef V8_TARGET_ARCH_ARM
#define RUNTIME_FUNCTION_LIST_DIRECT_CALL(F) \
  F(XXX, 2, 1, EXIT_FRAME_CALL)
#endif

and remove XXX from RUNTIME_FUNCTION_LIST_ALWAYS_X. Add the new list:

#define RUNTIME_FUNCTION_LIST(F) \
  RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
  RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
  RUNTIME_FUNCTION_LIST_DIRECT_CALL(F) \
  RUNTIME_FUNCTION_LIST_DEBUG(F) \
  RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
  RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F)

In runtime.cc have two "duplicate" versions of Runtime_XXX:

#ifdef DIRECT_CALL_SUPPORTED

static Object* Runtime_XXX(Object* x, Object* y) {
  // Full body.
}

#else

static Object* Runtime_XXX(Arguments args) {
  // Full body.
}

#endif


4. Port direct call to x64

5. Port direct call to ARM

6. Extend the number of runtime functions for which direct call is supported.

7. Add more advanced optimizations.

8. Goto 7 :-)

http://codereview.chromium.org/598072/diff/11034/10043
File src/ia32/macro-assembler-ia32.cc (right):

http://codereview.chromium.org/598072/diff/11034/10043#newcode1171
src/ia32/macro-assembler-ia32.cc:1171: 
I still think we should have the handling of calling a C function directly
abstracted into a PrepareCallCFunction function and retire FrameAlign etc. in
regexp-macro-assembler-ia32.cc.

As far as I can see you optimize the removal of the existing arguments into
restoring esp, and use push instead of
  mov(xxx, Operand(eax, Y * kPointerSize);
  mov(Operand(esp, X * kPointerSize), xxx);
I don't know whether it makes a performance difference, but if it does the
PrepareCallCFunction could take parameters to indicate whether the stack should
be prepared for push or storing into and number additional stack slots to get
rid of when restoring after alignment.

http://codereview.chromium.org/598072/diff/11034/10043#newcode1218
src/ia32/macro-assembler-ia32.cc:1218: }
Maybe just adjust the stack by f->nargs in an else to keep things simpler.
Otherwise please comment on then mov(esp, ... removes the arguments.

http://codereview.chromium.org/598072/diff/11034/10048
File src/runtime.h (right):

http://codereview.chromium.org/598072/diff/11034/10048#newcode376
src/runtime.h:376: DIRECT_CALL_NOT_FAILS
NOT -> NEVER.

Powered by Google App Engine
This is Rietveld 408576698