v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
arguments.cc
Go to the documentation of this file.
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #include "v8.h"
29 #include "arguments.h"
30 
31 #include "vm-state-inl.h"
32 
33 namespace v8 {
34 namespace internal {
35 
36 
37 template<typename T>
38 template<typename V>
40  // Check the ReturnValue.
41  Object** handle = &this->begin()[kReturnValueOffset];
42  // Nothing was set, return empty handle as per previous behaviour.
43  if ((*handle)->IsTheHole()) return v8::Handle<V>();
44  return Utils::Convert<Object, V>(Handle<Object>(handle));
45 }
46 
47 
49  Isolate* isolate = this->isolate();
50  VMState<EXTERNAL> state(isolate);
51  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
53  argv_,
54  argc_,
55  is_construct_call_);
56  f(info);
57  return GetReturnValue<v8::Value>(isolate);
58 }
59 
60 
61 #define WRITE_CALL_0(Function, ReturnValue) \
62 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f) { \
63  Isolate* isolate = this->isolate(); \
64  VMState<EXTERNAL> state(isolate); \
65  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
66  PropertyCallbackInfo<ReturnValue> info(begin()); \
67  f(info); \
68  return GetReturnValue<ReturnValue>(isolate); \
69 }
70 
71 
72 #define WRITE_CALL_1(Function, ReturnValue, Arg1) \
73 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f, \
74  Arg1 arg1) { \
75  Isolate* isolate = this->isolate(); \
76  VMState<EXTERNAL> state(isolate); \
77  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
78  PropertyCallbackInfo<ReturnValue> info(begin()); \
79  f(arg1, info); \
80  return GetReturnValue<ReturnValue>(isolate); \
81 }
82 
83 
84 #define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2) \
85 v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f, \
86  Arg1 arg1, \
87  Arg2 arg2) { \
88  Isolate* isolate = this->isolate(); \
89  VMState<EXTERNAL> state(isolate); \
90  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
91  PropertyCallbackInfo<ReturnValue> info(begin()); \
92  f(arg1, arg2, info); \
93  return GetReturnValue<ReturnValue>(isolate); \
94 }
95 
96 
97 #define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
98 void PropertyCallbackArguments::Call(Function f, \
99  Arg1 arg1, \
100  Arg2 arg2) { \
101  Isolate* isolate = this->isolate(); \
102  VMState<EXTERNAL> state(isolate); \
103  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
104  PropertyCallbackInfo<ReturnValue> info(begin()); \
105  f(arg1, arg2, info); \
106 }
107 
108 
113 
114 #undef WRITE_CALL_0
115 #undef WRITE_CALL_1
116 #undef WRITE_CALL_2
117 #undef WRITE_CALL_2_VOID
118 
119 
120 double ClobberDoubleRegisters(double x1, double x2, double x3, double x4) {
121  // TODO(ulan): This clobbers only subset of registers depending on compiler,
122  // Rewrite this in assembly to really clobber all registers.
123  // GCC for ia32 uses the FPU and does not touch XMM registers.
124  return x1 * 1.01 + x2 * 2.02 + x3 * 3.03 + x4 * 4.04;
125 }
126 
127 
128 } } // namespace v8::internal
#define FOR_EACH_CALLBACK_TABLE_MAPPING_0(F)
Definition: arguments.h:92
#define FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(F)
Definition: arguments.h:123
void(* FunctionCallback)(const FunctionCallbackInfo< Value > &info)
Definition: v8.h:2603
#define WRITE_CALL_0(Function, ReturnValue)
Definition: arguments.cc:61
v8::Handle< V > GetReturnValue(Isolate *isolate)
Definition: arguments.cc:39
#define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2)
Definition: arguments.cc:84
#define WRITE_CALL_1(Function, ReturnValue, Arg1)
Definition: arguments.cc:72
double ClobberDoubleRegisters(double x1, double x2, double x3, double x4)
Definition: arguments.cc:120
Definition: v8.h:123
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:103
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
Definition: flags.cc:317
v8::Handle< v8::Value > Call(FunctionCallback f)
Definition: arguments.cc:48
#define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2)
Definition: arguments.cc:97
#define FUNCTION_ADDR(f)
Definition: globals.h:345
#define FOR_EACH_CALLBACK_TABLE_MAPPING_1(F)
Definition: arguments.h:95
#define FOR_EACH_CALLBACK_TABLE_MAPPING_2(F)
Definition: arguments.h:113