1bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// Copyright 2013 the V8 project authors. All rights reserved.
2bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// Redistribution and use in source and binary forms, with or without
3bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// modification, are permitted provided that the following conditions are
4bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// met:
5bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//
6bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//     * Redistributions of source code must retain the above copyright
7bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//       notice, this list of conditions and the following disclaimer.
8bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//     * Redistributions in binary form must reproduce the above
9bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//       copyright notice, this list of conditions and the following
10bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//       disclaimer in the documentation and/or other materials provided
11bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//       with the distribution.
12bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//     * Neither the name of Google Inc. nor the names of its
13bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//       contributors may be used to endorse or promote products derived
14bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//       from this software without specific prior written permission.
15bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org//
16bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
28bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#include "v8.h"
29bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#include "arguments.h"
30bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
311510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org#include "vm-state-inl.h"
321510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
33bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgnamespace v8 {
34bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgnamespace internal {
35bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
36bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
37bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgstatic bool Match(void* a, void* b) {
38bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  return a == b;
39bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
40bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
41bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
42bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgstatic uint32_t Hash(void* function) {
43bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  uintptr_t as_int = reinterpret_cast<uintptr_t>(function);
44bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (sizeof(function) == 4) return static_cast<uint32_t>(as_int);
45bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  uint64_t as_64 = static_cast<uint64_t>(as_int);
46bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  return
47bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org      static_cast<uint32_t>(as_64 >> 32) ^
48bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org      static_cast<uint32_t>(as_64);
49bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
50bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
51bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
52bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgCallbackTable::CallbackTable(): map_(Match, 64) {}
53bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
54bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
55bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgbool CallbackTable::Contains(void* function) {
56bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  ASSERT(function != NULL);
57bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  return map_.Lookup(function, Hash(function), false) != NULL;
58bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
59bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
60bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
61bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgvoid CallbackTable::InsertCallback(Isolate* isolate,
62bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                           void* function,
63bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                           bool returns_void) {
64bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (function == NULL) return;
65bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  // Don't store for performance.
66bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (kStoreVoidFunctions != returns_void) return;
67bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  CallbackTable* table = isolate->callback_table();
68bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (table == NULL) {
69bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    table = new CallbackTable();
70bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    isolate->set_callback_table(table);
71bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  }
72bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  typedef HashMap::Entry Entry;
73bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  Entry* entry = table->map_.Lookup(function, Hash(function), true);
74bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  ASSERT(entry != NULL);
75bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  ASSERT(entry->value == NULL || entry->value == function);
76bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  entry->value = function;
77bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
78bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
79bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
80bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgtemplate<typename T>
81bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgtemplate<typename V>
82bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgv8::Handle<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) {
83bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  // Check the ReturnValue.
84bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  Object** handle = &this->end()[kReturnValueOffset];
85bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  // Nothing was set, return empty handle as per previous behaviour.
86bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if ((*handle)->IsTheHole()) return v8::Handle<V>();
87f95d4b920abb640ab0986d138ad559a7d3b91d04danno@chromium.org  return Utils::Convert<Object, V>(Handle<Object>(handle));
88bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
89bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
90bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
91bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgv8::Handle<v8::Value> FunctionCallbackArguments::Call(InvocationCallback f) {
92bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  Isolate* isolate = this->isolate();
93bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  void* f_as_void = CallbackTable::FunctionToVoidPtr(f);
94bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void);
951510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  VMState<EXTERNAL> state(isolate);
961510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
97bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (new_style) {
98bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    FunctionCallback c = reinterpret_cast<FunctionCallback>(f);
99bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    FunctionCallbackInfo<v8::Value> info(end(),
100bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                         argv_,
101bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                         argc_,
102bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                         is_construct_call_);
103bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    c(info);
104bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  } else {
105bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::Arguments args(end(),
106bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                       argv_,
107bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                       argc_,
108bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                       is_construct_call_);
109bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::Handle<v8::Value> return_value = f(args);
110bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    if (!return_value.IsEmpty()) return return_value;
111bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  }
112bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  return GetReturnValue<v8::Value>(isolate);
113bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
114bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
115bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
116bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#define WRITE_CALL_0(OldFunction, NewFunction, ReturnValue)                    \
117bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgv8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f) {       \
118bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  Isolate* isolate = this->isolate();                                          \
119bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  void* f_as_void = CallbackTable::FunctionToVoidPtr(f);                       \
120bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void);             \
1211510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  VMState<EXTERNAL> state(isolate);                                            \
1221510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));                 \
123bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (new_style) {                                                             \
124bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    NewFunction c = reinterpret_cast<NewFunction>(f);                          \
125bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    PropertyCallbackInfo<ReturnValue> info(end());                             \
126bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    c(info);                                                                   \
127bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  } else {                                                                     \
128bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::AccessorInfo info(end());                                              \
129bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::Handle<ReturnValue> return_value = f(info);                            \
130bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    if (!return_value.IsEmpty()) return return_value;                          \
131bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  }                                                                            \
132bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  return GetReturnValue<ReturnValue>(isolate);                                 \
133bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
134bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
135bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#define WRITE_CALL_1(OldFunction, NewFunction, ReturnValue, Arg1)              \
136bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgv8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f,         \
137bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                                        Arg1 arg1) {           \
138bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  Isolate* isolate = this->isolate();                                          \
139bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  void* f_as_void = CallbackTable::FunctionToVoidPtr(f);                       \
140bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void);             \
1411510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  VMState<EXTERNAL> state(isolate);                                            \
1421510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));                 \
143bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (new_style) {                                                             \
144bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    NewFunction c = reinterpret_cast<NewFunction>(f);                          \
145bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    PropertyCallbackInfo<ReturnValue> info(end());                             \
146bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    c(arg1, info);                                                             \
147bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  } else {                                                                     \
148bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::AccessorInfo info(end());                                              \
149bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::Handle<ReturnValue> return_value = f(arg1, info);                      \
150bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    if (!return_value.IsEmpty()) return return_value;                          \
151bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  }                                                                            \
152bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  return GetReturnValue<ReturnValue>(isolate);                                 \
153bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
154bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
155bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#define WRITE_CALL_2(OldFunction, NewFunction, ReturnValue, Arg1, Arg2)        \
156bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgv8::Handle<ReturnValue> PropertyCallbackArguments::Call(OldFunction f,         \
157bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                                        Arg1 arg1,             \
158bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                                        Arg2 arg2) {           \
159bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  Isolate* isolate = this->isolate();                                          \
160bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  void* f_as_void = CallbackTable::FunctionToVoidPtr(f);                       \
161bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void);             \
1621510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  VMState<EXTERNAL> state(isolate);                                            \
1631510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));                 \
164bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (new_style) {                                                             \
165bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    NewFunction c = reinterpret_cast<NewFunction>(f);                          \
166bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    PropertyCallbackInfo<ReturnValue> info(end());                             \
167bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    c(arg1, arg2, info);                                                       \
168bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  } else {                                                                     \
169bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::AccessorInfo info(end());                                              \
170bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::Handle<ReturnValue> return_value = f(arg1, arg2, info);                \
171bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    if (!return_value.IsEmpty()) return return_value;                          \
172bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  }                                                                            \
173bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  return GetReturnValue<ReturnValue>(isolate);                                 \
174bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
175bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
176bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#define WRITE_CALL_2_VOID(OldFunction, NewFunction, ReturnValue, Arg1, Arg2)   \
177bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgvoid PropertyCallbackArguments::Call(OldFunction f,                            \
178bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                     Arg1 arg1,                                \
179bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org                                     Arg2 arg2) {                              \
180bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  Isolate* isolate = this->isolate();                                          \
181bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  void* f_as_void = CallbackTable::FunctionToVoidPtr(f);                       \
182bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  bool new_style = CallbackTable::ReturnsVoid(isolate, f_as_void);             \
1831510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  VMState<EXTERNAL> state(isolate);                                            \
1841510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));                 \
185bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  if (new_style) {                                                             \
186bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    NewFunction c = reinterpret_cast<NewFunction>(f);                          \
187bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    PropertyCallbackInfo<ReturnValue> info(end());                             \
188bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    c(arg1, arg2, info);                                                       \
189bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  } else {                                                                     \
190bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    v8::AccessorInfo info(end());                                              \
191bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org    f(arg1, arg2, info);                                                       \
192bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  }                                                                            \
193bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org}
194bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
195bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgFOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
196bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgFOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
197bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgFOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
198bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.orgFOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
199bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
200bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#undef WRITE_CALL_0
201bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#undef WRITE_CALL_1
202bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#undef WRITE_CALL_2
203bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org#undef WRITE_CALL_2_VOID
204bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
205bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
206bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org} }  // namespace v8::internal
207bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org
208