| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/builtins.h" | 5 #include "src/builtins.h" | 
| 6 | 6 | 
| 7 #include "src/api.h" | 7 #include "src/api.h" | 
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" | 
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" | 
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 24 namespace v8 { | 24 namespace v8 { | 
| 25 namespace internal { | 25 namespace internal { | 
| 26 | 26 | 
| 27 namespace { | 27 namespace { | 
| 28 | 28 | 
| 29 // Arguments object passed to C++ builtins. | 29 // Arguments object passed to C++ builtins. | 
| 30 template <BuiltinExtraArguments extra_args> | 30 template <BuiltinExtraArguments extra_args> | 
| 31 class BuiltinArguments : public Arguments { | 31 class BuiltinArguments : public Arguments { | 
| 32  public: | 32  public: | 
| 33   BuiltinArguments(int length, Object** arguments) | 33   BuiltinArguments(int length, Object** arguments) | 
| 34       : Arguments(length, arguments) { } | 34       : Arguments(length, arguments) { | 
|  | 35     // Check we have at least the receiver. | 
|  | 36     DCHECK_LE(1, this->length()); | 
|  | 37   } | 
| 35 | 38 | 
| 36   Object*& operator[] (int index) { | 39   Object*& operator[] (int index) { | 
| 37     DCHECK(index < length()); | 40     DCHECK(index < length()); | 
| 38     return Arguments::operator[](index); | 41     return Arguments::operator[](index); | 
| 39   } | 42   } | 
| 40 | 43 | 
| 41   template <class S> Handle<S> at(int index) { | 44   template <class S> Handle<S> at(int index) { | 
| 42     DCHECK(index < length()); | 45     DCHECK(index < length()); | 
| 43     return Arguments::at<S>(index); | 46     return Arguments::at<S>(index); | 
| 44   } | 47   } | 
| 45 | 48 | 
| 46   Handle<Object> receiver() { | 49   Handle<Object> receiver() { | 
| 47     return Arguments::at<Object>(0); | 50     return Arguments::at<Object>(0); | 
| 48   } | 51   } | 
| 49 | 52 | 
| 50   Handle<JSFunction> called_function() { | 53   Handle<JSFunction> target(); | 
| 51     STATIC_ASSERT(extra_args == NEEDS_CALLED_FUNCTION); | 54   Handle<HeapObject> new_target(); | 
| 52     return Arguments::at<JSFunction>(Arguments::length() - 1); |  | 
| 53   } |  | 
| 54 | 55 | 
| 55   // Gets the total number of arguments including the receiver (but | 56   // Gets the total number of arguments including the receiver (but | 
| 56   // excluding extra arguments). | 57   // excluding extra arguments). | 
| 57   int length() const { | 58   int length() const; | 
| 58     STATIC_ASSERT(extra_args == NO_EXTRA_ARGUMENTS); |  | 
| 59     return Arguments::length(); |  | 
| 60   } |  | 
| 61 |  | 
| 62 #ifdef DEBUG |  | 
| 63   void Verify() { |  | 
| 64     // Check we have at least the receiver. |  | 
| 65     DCHECK(Arguments::length() >= 1); |  | 
| 66   } |  | 
| 67 #endif |  | 
| 68 }; | 59 }; | 
| 69 | 60 | 
| 70 | 61 | 
| 71 // Specialize BuiltinArguments for the called function extra argument. | 62 // Specialize BuiltinArguments for the extra arguments. | 
| 72 | 63 | 
| 73 template <> | 64 template <> | 
| 74 int BuiltinArguments<NEEDS_CALLED_FUNCTION>::length() const { | 65 int BuiltinArguments<BuiltinExtraArguments::kNone>::length() const { | 
|  | 66   return Arguments::length(); | 
|  | 67 } | 
|  | 68 | 
|  | 69 template <> | 
|  | 70 int BuiltinArguments<BuiltinExtraArguments::kTarget>::length() const { | 
| 75   return Arguments::length() - 1; | 71   return Arguments::length() - 1; | 
| 76 } | 72 } | 
| 77 | 73 | 
| 78 #ifdef DEBUG |  | 
| 79 template <> | 74 template <> | 
| 80 void BuiltinArguments<NEEDS_CALLED_FUNCTION>::Verify() { | 75 Handle<JSFunction> BuiltinArguments<BuiltinExtraArguments::kTarget>::target() { | 
| 81   // Check we have at least the receiver and the called function. | 76   return Arguments::at<JSFunction>(Arguments::length() - 1); | 
| 82   DCHECK(Arguments::length() >= 2); |  | 
| 83   // Make sure cast to JSFunction succeeds. |  | 
| 84   called_function(); |  | 
| 85 } | 77 } | 
| 86 #endif | 78 | 
|  | 79 template <> | 
|  | 80 int BuiltinArguments<BuiltinExtraArguments::kNewTarget>::length() const { | 
|  | 81   return Arguments::length() - 1; | 
|  | 82 } | 
|  | 83 | 
|  | 84 template <> | 
|  | 85 Handle<HeapObject> | 
|  | 86 BuiltinArguments<BuiltinExtraArguments::kNewTarget>::new_target() { | 
|  | 87   return Arguments::at<HeapObject>(Arguments::length() - 1); | 
|  | 88 } | 
|  | 89 | 
|  | 90 template <> | 
|  | 91 int BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>::length() | 
|  | 92     const { | 
|  | 93   return Arguments::length() - 2; | 
|  | 94 } | 
|  | 95 | 
|  | 96 template <> | 
|  | 97 Handle<JSFunction> | 
|  | 98 BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>::target() { | 
|  | 99   return Arguments::at<JSFunction>(Arguments::length() - 2); | 
|  | 100 } | 
|  | 101 | 
|  | 102 template <> | 
|  | 103 Handle<HeapObject> | 
|  | 104 BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>::new_target() { | 
|  | 105   return Arguments::at<HeapObject>(Arguments::length() - 1); | 
|  | 106 } | 
| 87 | 107 | 
| 88 | 108 | 
| 89 #define DEF_ARG_TYPE(name, spec)                      \ | 109 #define DEF_ARG_TYPE(name, spec) \ | 
| 90   typedef BuiltinArguments<spec> name##ArgumentsType; | 110   typedef BuiltinArguments<BuiltinExtraArguments::spec> name##ArgumentsType; | 
| 91 BUILTIN_LIST_C(DEF_ARG_TYPE) | 111 BUILTIN_LIST_C(DEF_ARG_TYPE) | 
| 92 #undef DEF_ARG_TYPE | 112 #undef DEF_ARG_TYPE | 
| 93 | 113 | 
| 94 | 114 | 
| 95 // ---------------------------------------------------------------------------- | 115 // ---------------------------------------------------------------------------- | 
| 96 // Support macro for defining builtins in C++. | 116 // Support macro for defining builtins in C++. | 
| 97 // ---------------------------------------------------------------------------- | 117 // ---------------------------------------------------------------------------- | 
| 98 // | 118 // | 
| 99 // A builtin function is defined by writing: | 119 // A builtin function is defined by writing: | 
| 100 // | 120 // | 
| 101 //   BUILTIN(name) { | 121 //   BUILTIN(name) { | 
| 102 //     ... | 122 //     ... | 
| 103 //   } | 123 //   } | 
| 104 // | 124 // | 
| 105 // In the body of the builtin function the arguments can be accessed | 125 // In the body of the builtin function the arguments can be accessed | 
| 106 // through the BuiltinArguments object args. | 126 // through the BuiltinArguments object args. | 
| 107 | 127 | 
| 108 #ifdef DEBUG |  | 
| 109 |  | 
| 110 #define BUILTIN(name)                                            \ | 128 #define BUILTIN(name)                                            \ | 
| 111   MUST_USE_RESULT static Object* Builtin_Impl_##name(            \ | 129   MUST_USE_RESULT static Object* Builtin_Impl_##name(            \ | 
| 112       name##ArgumentsType args, Isolate* isolate);               \ | 130       name##ArgumentsType args, Isolate* isolate);               \ | 
| 113   MUST_USE_RESULT static Object* Builtin_##name(                 \ | 131   MUST_USE_RESULT static Object* Builtin_##name(                 \ | 
| 114       int args_length, Object** args_object, Isolate* isolate) { \ | 132       int args_length, Object** args_object, Isolate* isolate) { \ | 
| 115     name##ArgumentsType args(args_length, args_object);          \ | 133     name##ArgumentsType args(args_length, args_object);          \ | 
| 116     args.Verify();                                               \ |  | 
| 117     return Builtin_Impl_##name(args, isolate);                   \ | 134     return Builtin_Impl_##name(args, isolate);                   \ | 
| 118   }                                                              \ | 135   }                                                              \ | 
| 119   MUST_USE_RESULT static Object* Builtin_Impl_##name(            \ | 136   MUST_USE_RESULT static Object* Builtin_Impl_##name(            \ | 
| 120       name##ArgumentsType args, Isolate* isolate) | 137       name##ArgumentsType args, Isolate* isolate) | 
| 121 | 138 | 
| 122 #else  // For release mode. |  | 
| 123 |  | 
| 124 #define BUILTIN(name)                                            \ |  | 
| 125   static Object* Builtin_impl##name(                             \ |  | 
| 126       name##ArgumentsType args, Isolate* isolate);               \ |  | 
| 127   static Object* Builtin_##name(                                 \ |  | 
| 128       int args_length, Object** args_object, Isolate* isolate) { \ |  | 
| 129     name##ArgumentsType args(args_length, args_object);          \ |  | 
| 130     return Builtin_impl##name(args, isolate);                    \ |  | 
| 131   }                                                              \ |  | 
| 132   static Object* Builtin_impl##name(                             \ |  | 
| 133       name##ArgumentsType args, Isolate* isolate) |  | 
| 134 #endif |  | 
| 135 |  | 
| 136 |  | 
| 137 #ifdef DEBUG |  | 
| 138 inline bool CalledAsConstructor(Isolate* isolate) { |  | 
| 139   // Calculate the result using a full stack frame iterator and check |  | 
| 140   // that the state of the stack is as we assume it to be in the |  | 
| 141   // code below. |  | 
| 142   StackFrameIterator it(isolate); |  | 
| 143   DCHECK(it.frame()->is_exit()); |  | 
| 144   it.Advance(); |  | 
| 145   StackFrame* frame = it.frame(); |  | 
| 146   bool reference_result = frame->is_construct(); |  | 
| 147   Address fp = Isolate::c_entry_fp(isolate->thread_local_top()); |  | 
| 148   // Because we know fp points to an exit frame we can use the relevant |  | 
| 149   // part of ExitFrame::ComputeCallerState directly. |  | 
| 150   const int kCallerOffset = ExitFrameConstants::kCallerFPOffset; |  | 
| 151   Address caller_fp = Memory::Address_at(fp + kCallerOffset); |  | 
| 152   // This inlines the part of StackFrame::ComputeType that grabs the |  | 
| 153   // type of the current frame.  Note that StackFrame::ComputeType |  | 
| 154   // has been specialized for each architecture so if any one of them |  | 
| 155   // changes this code has to be changed as well. |  | 
| 156   const int kMarkerOffset = StandardFrameConstants::kMarkerOffset; |  | 
| 157   const Smi* kConstructMarker = Smi::FromInt(StackFrame::CONSTRUCT); |  | 
| 158   Object* marker = Memory::Object_at(caller_fp + kMarkerOffset); |  | 
| 159   bool result = (marker == kConstructMarker); |  | 
| 160   DCHECK_EQ(result, reference_result); |  | 
| 161   return result; |  | 
| 162 } |  | 
| 163 #endif |  | 
| 164 |  | 
| 165 | 139 | 
| 166 // ---------------------------------------------------------------------------- | 140 // ---------------------------------------------------------------------------- | 
| 167 | 141 | 
| 168 | 142 | 
| 169 inline bool ClampedToInteger(Object* object, int* out) { | 143 inline bool ClampedToInteger(Object* object, int* out) { | 
| 170   // This is an extended version of ECMA-262 7.1.11 handling signed values | 144   // This is an extended version of ECMA-262 7.1.11 handling signed values | 
| 171   // Try to convert object to a number and clamp values to [kMinInt, kMaxInt] | 145   // Try to convert object to a number and clamp values to [kMinInt, kMaxInt] | 
| 172   if (object->IsSmi()) { | 146   if (object->IsSmi()) { | 
| 173     *out = Smi::cast(object)->value(); | 147     *out = Smi::cast(object)->value(); | 
| 174     return true; | 148     return true; | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 299   if (target_kind != origin_kind) { | 273   if (target_kind != origin_kind) { | 
| 300     JSObject::TransitionElementsKind(array, target_kind); | 274     JSObject::TransitionElementsKind(array, target_kind); | 
| 301     return handle(array->elements(), isolate); | 275     return handle(array->elements(), isolate); | 
| 302   } | 276   } | 
| 303   return elms; | 277   return elms; | 
| 304 } | 278 } | 
| 305 | 279 | 
| 306 | 280 | 
| 307 MUST_USE_RESULT static Object* CallJsIntrinsic( | 281 MUST_USE_RESULT static Object* CallJsIntrinsic( | 
| 308     Isolate* isolate, Handle<JSFunction> function, | 282     Isolate* isolate, Handle<JSFunction> function, | 
| 309     BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { | 283     BuiltinArguments<BuiltinExtraArguments::kNone> args) { | 
| 310   HandleScope handleScope(isolate); | 284   HandleScope handleScope(isolate); | 
| 311   int argc = args.length() - 1; | 285   int argc = args.length() - 1; | 
| 312   ScopedVector<Handle<Object> > argv(argc); | 286   ScopedVector<Handle<Object> > argv(argc); | 
| 313   for (int i = 0; i < argc; ++i) { | 287   for (int i = 0; i < argc; ++i) { | 
| 314     argv[i] = args.at<Object>(i + 1); | 288     argv[i] = args.at<Object>(i + 1); | 
| 315   } | 289   } | 
| 316   Handle<Object> result; | 290   Handle<Object> result; | 
| 317   ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 291   ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 
| 318       isolate, result, | 292       isolate, result, | 
| 319       Execution::Call(isolate, | 293       Execution::Call(isolate, | 
| (...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1757   } | 1731   } | 
| 1758   return *result; | 1732   return *result; | 
| 1759 } | 1733 } | 
| 1760 | 1734 | 
| 1761 | 1735 | 
| 1762 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case. | 1736 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case. | 
| 1763 BUILTIN(SymbolConstructor_ConstructStub) { | 1737 BUILTIN(SymbolConstructor_ConstructStub) { | 
| 1764   HandleScope scope(isolate); | 1738   HandleScope scope(isolate); | 
| 1765   // The ConstructStub is executed in the context of the caller, so we need | 1739   // The ConstructStub is executed in the context of the caller, so we need | 
| 1766   // to enter the callee context first before raising an exception. | 1740   // to enter the callee context first before raising an exception. | 
| 1767   isolate->set_context(args.called_function()->context()); | 1741   isolate->set_context(args.target()->context()); | 
| 1768   THROW_NEW_ERROR_RETURN_FAILURE( | 1742   THROW_NEW_ERROR_RETURN_FAILURE( | 
| 1769       isolate, NewTypeError(MessageTemplate::kNotConstructor, | 1743       isolate, NewTypeError(MessageTemplate::kNotConstructor, | 
| 1770                             isolate->factory()->Symbol_string())); | 1744                             isolate->factory()->Symbol_string())); | 
| 1771 } | 1745 } | 
| 1772 | 1746 | 
| 1773 | 1747 | 
| 1774 // ----------------------------------------------------------------------------- | 1748 // ----------------------------------------------------------------------------- | 
| 1775 // Throwers for restricted function properties and strict arguments object | 1749 // Throwers for restricted function properties and strict arguments object | 
| 1776 // properties | 1750 // properties | 
| 1777 | 1751 | 
| 1778 | 1752 | 
| 1779 BUILTIN(RestrictedFunctionPropertiesThrower) { | 1753 BUILTIN(RestrictedFunctionPropertiesThrower) { | 
| 1780   HandleScope scope(isolate); | 1754   HandleScope scope(isolate); | 
| 1781   THROW_NEW_ERROR_RETURN_FAILURE( | 1755   THROW_NEW_ERROR_RETURN_FAILURE( | 
| 1782       isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties)); | 1756       isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties)); | 
| 1783 } | 1757 } | 
| 1784 | 1758 | 
| 1785 | 1759 | 
| 1786 BUILTIN(RestrictedStrictArgumentsPropertiesThrower) { | 1760 BUILTIN(RestrictedStrictArgumentsPropertiesThrower) { | 
| 1787   HandleScope scope(isolate); | 1761   HandleScope scope(isolate); | 
| 1788   THROW_NEW_ERROR_RETURN_FAILURE( | 1762   THROW_NEW_ERROR_RETURN_FAILURE( | 
| 1789       isolate, NewTypeError(MessageTemplate::kStrictPoisonPill)); | 1763       isolate, NewTypeError(MessageTemplate::kStrictPoisonPill)); | 
| 1790 } | 1764 } | 
| 1791 | 1765 | 
| 1792 | 1766 | 
| 1793 // ----------------------------------------------------------------------------- | 1767 // ----------------------------------------------------------------------------- | 
| 1794 // | 1768 // | 
| 1795 | 1769 | 
| 1796 | 1770 | 
|  | 1771 namespace { | 
|  | 1772 | 
| 1797 template <bool is_construct> | 1773 template <bool is_construct> | 
| 1798 MUST_USE_RESULT static MaybeHandle<Object> HandleApiCallHelper( | 1774 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( | 
| 1799     Isolate* isolate, BuiltinArguments<NEEDS_CALLED_FUNCTION>& args) { | 1775     Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) { | 
| 1800   HandleScope scope(isolate); | 1776   HandleScope scope(isolate); | 
| 1801   Handle<JSFunction> function = args.called_function(); | 1777   Handle<JSFunction> function = args.target(); | 
| 1802   // TODO(ishell): turn this back to a DCHECK. | 1778   // TODO(ishell): turn this back to a DCHECK. | 
| 1803   CHECK(function->shared()->IsApiFunction()); | 1779   CHECK(function->shared()->IsApiFunction()); | 
| 1804 | 1780 | 
| 1805   Handle<FunctionTemplateInfo> fun_data( | 1781   Handle<FunctionTemplateInfo> fun_data( | 
| 1806       function->shared()->get_api_func_data(), isolate); | 1782       function->shared()->get_api_func_data(), isolate); | 
| 1807   if (is_construct) { | 1783   if (is_construct) { | 
| 1808     ASSIGN_RETURN_ON_EXCEPTION( | 1784     ASSIGN_RETURN_ON_EXCEPTION( | 
| 1809         isolate, fun_data, | 1785         isolate, fun_data, | 
| 1810         ApiNatives::ConfigureInstance(isolate, fun_data, | 1786         ApiNatives::ConfigureInstance(isolate, fun_data, | 
| 1811                                       Handle<JSObject>::cast(args.receiver())), | 1787                                       Handle<JSObject>::cast(args.receiver())), | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1866 | 1842 | 
| 1867     RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 1843     RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 
| 1868     if (!is_construct || result->IsJSObject()) { | 1844     if (!is_construct || result->IsJSObject()) { | 
| 1869       return scope.CloseAndEscape(result); | 1845       return scope.CloseAndEscape(result); | 
| 1870     } | 1846     } | 
| 1871   } | 1847   } | 
| 1872 | 1848 | 
| 1873   return scope.CloseAndEscape(args.receiver()); | 1849   return scope.CloseAndEscape(args.receiver()); | 
| 1874 } | 1850 } | 
| 1875 | 1851 | 
|  | 1852 }  // namespace | 
|  | 1853 | 
| 1876 | 1854 | 
| 1877 BUILTIN(HandleApiCall) { | 1855 BUILTIN(HandleApiCall) { | 
| 1878   HandleScope scope(isolate); | 1856   HandleScope scope(isolate); | 
| 1879   DCHECK(!CalledAsConstructor(isolate)); |  | 
| 1880   Handle<Object> result; | 1857   Handle<Object> result; | 
| 1881   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 1858   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 
| 1882                                      HandleApiCallHelper<false>(isolate, args)); | 1859                                      HandleApiCallHelper<false>(isolate, args)); | 
| 1883   return *result; | 1860   return *result; | 
| 1884 } | 1861 } | 
| 1885 | 1862 | 
| 1886 | 1863 | 
| 1887 BUILTIN(HandleApiCallConstruct) { | 1864 BUILTIN(HandleApiCallConstruct) { | 
| 1888   HandleScope scope(isolate); | 1865   HandleScope scope(isolate); | 
| 1889   DCHECK(CalledAsConstructor(isolate)); |  | 
| 1890   Handle<Object> result; | 1866   Handle<Object> result; | 
| 1891   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 1867   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 
| 1892                                      HandleApiCallHelper<true>(isolate, args)); | 1868                                      HandleApiCallHelper<true>(isolate, args)); | 
| 1893   return *result; | 1869   return *result; | 
| 1894 } | 1870 } | 
| 1895 | 1871 | 
| 1896 | 1872 | 
| 1897 Handle<Code> Builtins::CallFunction(ConvertReceiverMode mode) { | 1873 Handle<Code> Builtins::CallFunction(ConvertReceiverMode mode) { | 
| 1898   switch (mode) { | 1874   switch (mode) { | 
| 1899     case ConvertReceiverMode::kNullOrUndefined: | 1875     case ConvertReceiverMode::kNullOrUndefined: | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 1917     case ConvertReceiverMode::kAny: | 1893     case ConvertReceiverMode::kAny: | 
| 1918       return Call_ReceiverIsAny(); | 1894       return Call_ReceiverIsAny(); | 
| 1919   } | 1895   } | 
| 1920   UNREACHABLE(); | 1896   UNREACHABLE(); | 
| 1921   return Handle<Code>::null(); | 1897   return Handle<Code>::null(); | 
| 1922 } | 1898 } | 
| 1923 | 1899 | 
| 1924 | 1900 | 
| 1925 namespace { | 1901 namespace { | 
| 1926 | 1902 | 
| 1927 class RelocatableArguments : public BuiltinArguments<NEEDS_CALLED_FUNCTION>, | 1903 class RelocatableArguments | 
| 1928                              public Relocatable { | 1904     : public BuiltinArguments<BuiltinExtraArguments::kTarget>, | 
|  | 1905       public Relocatable { | 
| 1929  public: | 1906  public: | 
| 1930   RelocatableArguments(Isolate* isolate, int length, Object** arguments) | 1907   RelocatableArguments(Isolate* isolate, int length, Object** arguments) | 
| 1931       : BuiltinArguments<NEEDS_CALLED_FUNCTION>(length, arguments), | 1908       : BuiltinArguments<BuiltinExtraArguments::kTarget>(length, arguments), | 
| 1932         Relocatable(isolate) {} | 1909         Relocatable(isolate) {} | 
| 1933 | 1910 | 
| 1934   virtual inline void IterateInstance(ObjectVisitor* v) { | 1911   virtual inline void IterateInstance(ObjectVisitor* v) { | 
| 1935     if (length() == 0) return; | 1912     if (length() == 0) return; | 
| 1936     v->VisitPointers(lowest_address(), highest_address() + 1); | 1913     v->VisitPointers(lowest_address(), highest_address() + 1); | 
| 1937   } | 1914   } | 
| 1938 | 1915 | 
| 1939  private: | 1916  private: | 
| 1940   DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); | 1917   DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); | 
| 1941 }; | 1918 }; | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 1971     delete[] argv; | 1948     delete[] argv; | 
| 1972   } | 1949   } | 
| 1973   return result; | 1950   return result; | 
| 1974 } | 1951 } | 
| 1975 | 1952 | 
| 1976 | 1953 | 
| 1977 // Helper function to handle calls to non-function objects created through the | 1954 // Helper function to handle calls to non-function objects created through the | 
| 1978 // API. The object can be called as either a constructor (using new) or just as | 1955 // API. The object can be called as either a constructor (using new) or just as | 
| 1979 // a function (without new). | 1956 // a function (without new). | 
| 1980 MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor( | 1957 MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor( | 
| 1981     Isolate* isolate, | 1958     Isolate* isolate, bool is_construct_call, | 
| 1982     bool is_construct_call, | 1959     BuiltinArguments<BuiltinExtraArguments::kNone> args) { | 
| 1983     BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { |  | 
| 1984   // Non-functions are never called as constructors. Even if this is an object |  | 
| 1985   // called as a constructor the delegate call is not a construct call. |  | 
| 1986   DCHECK(!CalledAsConstructor(isolate)); |  | 
| 1987   Heap* heap = isolate->heap(); | 1960   Heap* heap = isolate->heap(); | 
| 1988 | 1961 | 
| 1989   Handle<Object> receiver = args.receiver(); | 1962   Handle<Object> receiver = args.receiver(); | 
| 1990 | 1963 | 
| 1991   // Get the object called. | 1964   // Get the object called. | 
| 1992   JSObject* obj = JSObject::cast(*receiver); | 1965   JSObject* obj = JSObject::cast(*receiver); | 
| 1993 | 1966 | 
| 1994   // Get the invocation callback from the function descriptor that was | 1967   // Get the invocation callback from the function descriptor that was | 
| 1995   // used to create the called object. | 1968   // used to create the called object. | 
| 1996   DCHECK(obj->map()->is_callable()); | 1969   DCHECK(obj->map()->is_callable()); | 
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2233 // We do this in a sort of roundabout way so that we can do the initialization | 2206 // We do this in a sort of roundabout way so that we can do the initialization | 
| 2234 // within the lexical scope of Builtins:: and within a context where | 2207 // within the lexical scope of Builtins:: and within a context where | 
| 2235 // Code::Flags names a non-abstract type. | 2208 // Code::Flags names a non-abstract type. | 
| 2236 void Builtins::InitBuiltinFunctionTable() { | 2209 void Builtins::InitBuiltinFunctionTable() { | 
| 2237   BuiltinDesc* functions = builtin_function_table.functions_; | 2210   BuiltinDesc* functions = builtin_function_table.functions_; | 
| 2238   functions[builtin_count].generator = NULL; | 2211   functions[builtin_count].generator = NULL; | 
| 2239   functions[builtin_count].c_code = NULL; | 2212   functions[builtin_count].c_code = NULL; | 
| 2240   functions[builtin_count].s_name = NULL; | 2213   functions[builtin_count].s_name = NULL; | 
| 2241   functions[builtin_count].name = builtin_count; | 2214   functions[builtin_count].name = builtin_count; | 
| 2242   functions[builtin_count].flags = static_cast<Code::Flags>(0); | 2215   functions[builtin_count].flags = static_cast<Code::Flags>(0); | 
| 2243   functions[builtin_count].extra_args = NO_EXTRA_ARGUMENTS; | 2216   functions[builtin_count].extra_args = BuiltinExtraArguments::kNone; | 
| 2244 | 2217 | 
| 2245 #define DEF_FUNCTION_PTR_C(aname, aextra_args)                         \ | 2218 #define DEF_FUNCTION_PTR_C(aname, aextra_args)                \ | 
| 2246     functions->generator = FUNCTION_ADDR(Generate_Adaptor);            \ | 2219   functions->generator = FUNCTION_ADDR(Generate_Adaptor);     \ | 
| 2247     functions->c_code = FUNCTION_ADDR(Builtin_##aname);                \ | 2220   functions->c_code = FUNCTION_ADDR(Builtin_##aname);         \ | 
| 2248     functions->s_name = #aname;                                        \ | 2221   functions->s_name = #aname;                                 \ | 
| 2249     functions->name = c_##aname;                                       \ | 2222   functions->name = c_##aname;                                \ | 
| 2250     functions->flags = Code::ComputeFlags(Code::BUILTIN);              \ | 2223   functions->flags = Code::ComputeFlags(Code::BUILTIN);       \ | 
| 2251     functions->extra_args = aextra_args;                               \ | 2224   functions->extra_args = BuiltinExtraArguments::aextra_args; \ | 
| 2252     ++functions; | 2225   ++functions; | 
| 2253 | 2226 | 
| 2254 #define DEF_FUNCTION_PTR_A(aname, kind, state, extra)                       \ | 2227 #define DEF_FUNCTION_PTR_A(aname, kind, state, extra)              \ | 
| 2255     functions->generator = FUNCTION_ADDR(Generate_##aname);                 \ | 2228   functions->generator = FUNCTION_ADDR(Generate_##aname);          \ | 
| 2256     functions->c_code = NULL;                                               \ | 2229   functions->c_code = NULL;                                        \ | 
| 2257     functions->s_name = #aname;                                             \ | 2230   functions->s_name = #aname;                                      \ | 
| 2258     functions->name = k##aname;                                             \ | 2231   functions->name = k##aname;                                      \ | 
| 2259     functions->flags = Code::ComputeFlags(Code::kind,                       \ | 2232   functions->flags = Code::ComputeFlags(Code::kind, state, extra); \ | 
| 2260                                           state,                            \ | 2233   functions->extra_args = BuiltinExtraArguments::kNone;            \ | 
| 2261                                           extra);                           \ | 2234   ++functions; | 
| 2262     functions->extra_args = NO_EXTRA_ARGUMENTS;                             \ |  | 
| 2263     ++functions; |  | 
| 2264 | 2235 | 
| 2265 #define DEF_FUNCTION_PTR_H(aname, kind)                                     \ | 2236 #define DEF_FUNCTION_PTR_H(aname, kind)                     \ | 
| 2266     functions->generator = FUNCTION_ADDR(Generate_##aname);                 \ | 2237   functions->generator = FUNCTION_ADDR(Generate_##aname);   \ | 
| 2267     functions->c_code = NULL;                                               \ | 2238   functions->c_code = NULL;                                 \ | 
| 2268     functions->s_name = #aname;                                             \ | 2239   functions->s_name = #aname;                               \ | 
| 2269     functions->name = k##aname;                                             \ | 2240   functions->name = k##aname;                               \ | 
| 2270     functions->flags = Code::ComputeHandlerFlags(Code::kind);               \ | 2241   functions->flags = Code::ComputeHandlerFlags(Code::kind); \ | 
| 2271     functions->extra_args = NO_EXTRA_ARGUMENTS;                             \ | 2242   functions->extra_args = BuiltinExtraArguments::kNone;     \ | 
| 2272     ++functions; | 2243   ++functions; | 
| 2273 | 2244 | 
| 2274   BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) | 2245   BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) | 
| 2275   BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) | 2246   BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) | 
| 2276   BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) | 2247   BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) | 
| 2277   BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) | 2248   BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) | 
| 2278 | 2249 | 
| 2279 #undef DEF_FUNCTION_PTR_C | 2250 #undef DEF_FUNCTION_PTR_C | 
| 2280 #undef DEF_FUNCTION_PTR_A | 2251 #undef DEF_FUNCTION_PTR_A | 
| 2281 } | 2252 } | 
| 2282 | 2253 | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2404 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2375 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 
| 2405 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2376 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 2406 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2377 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 
| 2407 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2378 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 2408 #undef DEFINE_BUILTIN_ACCESSOR_C | 2379 #undef DEFINE_BUILTIN_ACCESSOR_C | 
| 2409 #undef DEFINE_BUILTIN_ACCESSOR_A | 2380 #undef DEFINE_BUILTIN_ACCESSOR_A | 
| 2410 | 2381 | 
| 2411 | 2382 | 
| 2412 }  // namespace internal | 2383 }  // namespace internal | 
| 2413 }  // namespace v8 | 2384 }  // namespace v8 | 
| OLD | NEW | 
|---|