JavascriptLibraryBase.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // JavascriptLibraryBase.h is used by static lib shared between Trident and Chakra. We need to keep
  6. // the size consistent and try not to change its size. We need to have matching mshtml.dll
  7. // if the size changed here.
  8. #pragma once
  9. namespace Js
  10. {
  11. class EngineInterfaceObject;
  12. class JavascriptLibraryBase : public FinalizableObject
  13. {
  14. friend class JavascriptLibrary;
  15. friend class ScriptSite;
  16. public:
  17. JavascriptLibraryBase(GlobalObject* globalObject):
  18. globalObject(globalObject)
  19. {
  20. }
  21. Var GetPI() { return pi; }
  22. Var GetNaN() { return nan; }
  23. Var GetNegativeInfinite() { return negativeInfinite; }
  24. Var GetPositiveInfinite() { return positiveInfinite; }
  25. Var GetMaxValue() { return maxValue; }
  26. Var GetMinValue() { return minValue; }
  27. Var GetNegativeZero() { return negativeZero; }
  28. RecyclableObject* GetUndefined() { return undefinedValue; }
  29. RecyclableObject* GetNull() { return nullValue; }
  30. JavascriptBoolean* GetTrue() { return booleanTrue; }
  31. JavascriptBoolean* GetFalse() { return booleanFalse; }
  32. JavascriptSymbol* GetSymbolHasInstance() { return symbolHasInstance; }
  33. JavascriptSymbol* GetSymbolIsConcatSpreadable() { return symbolIsConcatSpreadable; }
  34. JavascriptSymbol* GetSymbolIterator() { return symbolIterator; }
  35. JavascriptSymbol* GetSymbolToPrimitive() { return symbolToPrimitive; }
  36. JavascriptSymbol* GetSymbolToStringTag() { return symbolToStringTag; }
  37. JavascriptSymbol* GetSymbolUnscopables() { return symbolUnscopables; }
  38. JavascriptFunction* GetObjectConstructor() { return objectConstructor; }
  39. JavascriptFunction* GetArrayConstructor() { return arrayConstructor; }
  40. JavascriptFunction* GetBooleanConstructor() { return booleanConstructor; }
  41. JavascriptFunction* GetDateConstructor() { return dateConstructor; }
  42. JavascriptFunction* GetFunctionConstructor() { return functionConstructor; }
  43. JavascriptFunction* GetNumberConstructor() { return numberConstructor; }
  44. JavascriptRegExpConstructor* GetRegExpConstructor() { return regexConstructor; }
  45. JavascriptFunction* GetStringConstructor() { return stringConstructor; }
  46. JavascriptFunction* GetArrayBufferConstructor() { return arrayBufferConstructor; }
  47. JavascriptFunction* GetPixelArrayConstructor() { return pixelArrayConstructor; }
  48. JavascriptFunction* GetTypedArrayConstructor() const { return typedArrayConstructor; }
  49. JavascriptFunction* GetInt8ArrayConstructor() { return Int8ArrayConstructor; }
  50. JavascriptFunction* GetUint8ArrayConstructor() { return Uint8ArrayConstructor; }
  51. JavascriptFunction* GetUint8ClampedArrayConstructor() { return Uint8ClampedArrayConstructor; }
  52. JavascriptFunction* GetInt16ArrayConstructor() { return Int16ArrayConstructor; }
  53. JavascriptFunction* GetUint16ArrayConstructor() { return Uint16ArrayConstructor; }
  54. JavascriptFunction* GetInt32ArrayConstructor() { return Int32ArrayConstructor; }
  55. JavascriptFunction* GetUint32ArrayConstructor() { return Uint32ArrayConstructor; }
  56. JavascriptFunction* GetFloat32ArrayConstructor() { return Float32ArrayConstructor; }
  57. JavascriptFunction* GetFloat64ArrayConstructor() { return Float64ArrayConstructor; }
  58. JavascriptFunction* GetMapConstructor() { return mapConstructor; }
  59. JavascriptFunction* GetSetConstructor() { return setConstructor; }
  60. JavascriptFunction* GetWeakMapConstructor() { return weakMapConstructor; }
  61. JavascriptFunction* GetWeakSetConstructor() { return weakSetConstructor; }
  62. JavascriptFunction* GetSymbolConstructor() { return symbolConstructor; }
  63. JavascriptFunction* GetProxyConstructor() const { return proxyConstructor; }
  64. JavascriptFunction* GetPromiseConstructor() const { return promiseConstructor; }
  65. JavascriptFunction* GetGeneratorFunctionConstructor() const { return generatorFunctionConstructor; }
  66. JavascriptFunction* GetAsyncFunctionConstructor() const { return asyncFunctionConstructor; }
  67. JavascriptFunction* GetErrorConstructor() const { return errorConstructor; }
  68. JavascriptFunction* GetEvalErrorConstructor() const { return evalErrorConstructor; }
  69. JavascriptFunction* GetRangeErrorConstructor() const { return rangeErrorConstructor; }
  70. JavascriptFunction* GetReferenceErrorConstructor() const { return referenceErrorConstructor; }
  71. JavascriptFunction* GetSyntaxErrorConstructor() const { return syntaxErrorConstructor; }
  72. JavascriptFunction* GetTypeErrorConstructor() const { return typeErrorConstructor; }
  73. JavascriptFunction* GetURIErrorConstructor() const { return uriErrorConstructor; }
  74. DynamicObject* GetMathObject() { return mathObject; }
  75. DynamicObject* GetJSONObject() { return JSONObject; }
  76. #ifdef ENABLE_INTL_OBJECT
  77. DynamicObject* GetINTLObject() { return IntlObject; }
  78. #endif
  79. #if defined(ENABLE_INTL_OBJECT) || defined(ENABLE_PROJECTION)
  80. EngineInterfaceObject* GetEngineInterfaceObject() { return engineInterfaceObject; }
  81. #endif
  82. DynamicObject* GetArrayPrototype() { return arrayPrototype; }
  83. DynamicObject* GetBooleanPrototype() { return booleanPrototype; }
  84. DynamicObject* GetDatePrototype() { return datePrototype; }
  85. DynamicObject* GetFunctionPrototype() { return functionPrototype; }
  86. DynamicObject* GetNumberPrototype() { return numberPrototype; }
  87. DynamicObject* GetSIMDBool8x16Prototype() { return simdBool8x16Prototype; }
  88. DynamicObject* GetSIMDBool16x8Prototype() { return simdBool16x8Prototype; }
  89. DynamicObject* GetSIMDBool32x4Prototype() { return simdBool32x4Prototype; }
  90. DynamicObject* GetSIMDInt8x16Prototype() { return simdInt8x16Prototype; }
  91. DynamicObject* GetSIMDInt16x8Prototype() { return simdInt16x8Prototype; }
  92. DynamicObject* GetSIMDInt32x4Prototype() { return simdInt32x4Prototype; }
  93. DynamicObject* GetSIMDUint8x16Prototype() { return simdUint8x16Prototype; }
  94. DynamicObject* GetSIMDUint16x8Prototype() { return simdUint16x8Prototype; }
  95. DynamicObject* GetSIMDUint32x4Prototype() { return simdUint32x4Prototype; }
  96. DynamicObject* GetSIMDFloat32x4Prototype() { return simdFloat32x4Prototype; }
  97. DynamicObject* GetSIMDFloat64x2Prototype() { return simdFloat64x2Prototype; }
  98. ObjectPrototypeObject* GetObjectPrototypeObject() { return objectPrototype; }
  99. DynamicObject* GetObjectPrototype();
  100. DynamicObject* GetRegExpPrototype() { return regexPrototype; }
  101. DynamicObject* GetStringPrototype() { return stringPrototype; }
  102. DynamicObject* GetMapPrototype() { return mapPrototype; }
  103. DynamicObject* GetSetPrototype() { return setPrototype; }
  104. DynamicObject* GetWeakMapPrototype() { return weakMapPrototype; }
  105. DynamicObject* GetWeakSetPrototype() { return weakSetPrototype; }
  106. DynamicObject* GetSymbolPrototype() { return symbolPrototype; }
  107. DynamicObject* GetArrayIteratorPrototype() const { return arrayIteratorPrototype; }
  108. DynamicObject* GetMapIteratorPrototype() const { return mapIteratorPrototype; }
  109. DynamicObject* GetSetIteratorPrototype() const { return setIteratorPrototype; }
  110. DynamicObject* GetStringIteratorPrototype() const { return stringIteratorPrototype; }
  111. DynamicObject* GetPromisePrototype() const { return promisePrototype; }
  112. DynamicObject* GetJavascriptEnumeratorIteratorPrototype() const { return javascriptEnumeratorIteratorPrototype; }
  113. DynamicObject* GetGeneratorFunctionPrototype() const { return generatorFunctionPrototype; }
  114. DynamicObject* GetGeneratorPrototype() const { return generatorPrototype; }
  115. DynamicObject* GetAsyncFunctionPrototype() const { return asyncFunctionPrototype; }
  116. DynamicObject* GetErrorPrototype() const { return errorPrototype; }
  117. DynamicObject* GetEvalErrorPrototype() const { return evalErrorPrototype; }
  118. DynamicObject* GetRangeErrorPrototype() const { return rangeErrorPrototype; }
  119. DynamicObject* GetReferenceErrorPrototype() const { return referenceErrorPrototype; }
  120. DynamicObject* GetSyntaxErrorPrototype() const { return syntaxErrorPrototype; }
  121. DynamicObject* GetTypeErrorPrototype() const { return typeErrorPrototype; }
  122. DynamicObject* GetURIErrorPrototype() const { return uriErrorPrototype; }
  123. protected:
  124. GlobalObject* globalObject;
  125. RuntimeFunction* mapConstructor;
  126. RuntimeFunction* setConstructor;
  127. RuntimeFunction* weakMapConstructor;
  128. RuntimeFunction* weakSetConstructor;
  129. RuntimeFunction* arrayConstructor;
  130. RuntimeFunction* typedArrayConstructor;
  131. RuntimeFunction* Int8ArrayConstructor;
  132. RuntimeFunction* Uint8ArrayConstructor;
  133. RuntimeFunction* Uint8ClampedArrayConstructor;
  134. RuntimeFunction* Int16ArrayConstructor;
  135. RuntimeFunction* Uint16ArrayConstructor;
  136. RuntimeFunction* Int32ArrayConstructor;
  137. RuntimeFunction* Uint32ArrayConstructor;
  138. RuntimeFunction* Float32ArrayConstructor;
  139. RuntimeFunction* Float64ArrayConstructor;
  140. RuntimeFunction* arrayBufferConstructor;
  141. RuntimeFunction* dataViewConstructor;
  142. RuntimeFunction* booleanConstructor;
  143. RuntimeFunction* dateConstructor;
  144. RuntimeFunction* functionConstructor;
  145. RuntimeFunction* numberConstructor;
  146. RuntimeFunction* objectConstructor;
  147. RuntimeFunction* symbolConstructor;
  148. JavascriptRegExpConstructor* regexConstructor;
  149. RuntimeFunction* stringConstructor;
  150. RuntimeFunction* pixelArrayConstructor;
  151. RuntimeFunction* errorConstructor;
  152. RuntimeFunction* evalErrorConstructor;
  153. RuntimeFunction* rangeErrorConstructor;
  154. RuntimeFunction* referenceErrorConstructor;
  155. RuntimeFunction* syntaxErrorConstructor;
  156. RuntimeFunction* typeErrorConstructor;
  157. RuntimeFunction* uriErrorConstructor;
  158. RuntimeFunction* proxyConstructor;
  159. RuntimeFunction* promiseConstructor;
  160. RuntimeFunction* generatorFunctionConstructor;
  161. RuntimeFunction* asyncFunctionConstructor;
  162. JavascriptFunction* defaultAccessorFunction;
  163. JavascriptFunction* stackTraceAccessorFunction;
  164. JavascriptFunction* throwTypeErrorAccessorFunction;
  165. JavascriptFunction* throwTypeErrorCallerAccessorFunction;
  166. JavascriptFunction* throwTypeErrorCalleeAccessorFunction;
  167. JavascriptFunction* throwTypeErrorArgumentsAccessorFunction;
  168. JavascriptFunction* debugObjectNonUserGetterFunction;
  169. JavascriptFunction* debugObjectNonUserSetterFunction;
  170. JavascriptFunction* debugObjectDebugModeGetterFunction;
  171. JavascriptFunction* __proto__getterFunction;
  172. JavascriptFunction* __proto__setterFunction;
  173. DynamicObject* mathObject;
  174. // SIMD_JS
  175. DynamicObject* simdObject;
  176. DynamicObject* debugObject;
  177. DynamicObject* JSONObject;
  178. #ifdef ENABLE_INTL_OBJECT
  179. DynamicObject* IntlObject;
  180. #endif
  181. #if defined(ENABLE_INTL_OBJECT) || defined(ENABLE_PROJECTION)
  182. EngineInterfaceObject* engineInterfaceObject;
  183. #endif
  184. DynamicObject* reflectObject;
  185. DynamicObject* arrayPrototype;
  186. DynamicObject* typedArrayPrototype;
  187. DynamicObject* Int8ArrayPrototype;
  188. DynamicObject* Uint8ArrayPrototype;
  189. DynamicObject* Uint8ClampedArrayPrototype;
  190. DynamicObject* Int16ArrayPrototype;
  191. DynamicObject* Uint16ArrayPrototype;
  192. DynamicObject* Int32ArrayPrototype;
  193. DynamicObject* Uint32ArrayPrototype;
  194. DynamicObject* Float32ArrayPrototype;
  195. DynamicObject* Float64ArrayPrototype;
  196. DynamicObject* Int64ArrayPrototype;
  197. DynamicObject* Uint64ArrayPrototype;
  198. DynamicObject* BoolArrayPrototype;
  199. DynamicObject* CharArrayPrototype;
  200. DynamicObject* arrayBufferPrototype;
  201. DynamicObject* dataViewPrototype;
  202. DynamicObject* pixelArrayPrototype;
  203. DynamicObject* booleanPrototype;
  204. DynamicObject* datePrototype;
  205. DynamicObject* functionPrototype;
  206. DynamicObject* numberPrototype;
  207. ObjectPrototypeObject* objectPrototype;
  208. DynamicObject* regexPrototype;
  209. DynamicObject* stringPrototype;
  210. DynamicObject* mapPrototype;
  211. DynamicObject* setPrototype;
  212. DynamicObject* weakMapPrototype;
  213. DynamicObject* weakSetPrototype;
  214. DynamicObject* symbolPrototype;
  215. DynamicObject* iteratorPrototype; // aka %IteratorPrototype%
  216. DynamicObject* arrayIteratorPrototype;
  217. DynamicObject* mapIteratorPrototype;
  218. DynamicObject* setIteratorPrototype;
  219. DynamicObject* stringIteratorPrototype;
  220. DynamicObject* promisePrototype;
  221. DynamicObject* javascriptEnumeratorIteratorPrototype;
  222. DynamicObject* generatorFunctionPrototype; // aka %Generator%
  223. DynamicObject* generatorPrototype; // aka %GeneratorPrototype%
  224. DynamicObject* asyncFunctionPrototype; // aka %AsyncFunctionPrototype%
  225. DynamicObject* errorPrototype;
  226. DynamicObject* evalErrorPrototype;
  227. DynamicObject* rangeErrorPrototype;
  228. DynamicObject* referenceErrorPrototype;
  229. DynamicObject* syntaxErrorPrototype;
  230. DynamicObject* typeErrorPrototype;
  231. DynamicObject* uriErrorPrototype;
  232. //SIMD Prototypes
  233. DynamicObject* simdBool8x16Prototype;
  234. DynamicObject* simdBool16x8Prototype;
  235. DynamicObject* simdBool32x4Prototype;
  236. DynamicObject* simdInt8x16Prototype;
  237. DynamicObject* simdInt16x8Prototype;
  238. DynamicObject* simdInt32x4Prototype;
  239. DynamicObject* simdUint8x16Prototype;
  240. DynamicObject* simdUint16x8Prototype;
  241. DynamicObject* simdUint32x4Prototype;
  242. DynamicObject* simdFloat32x4Prototype;
  243. DynamicObject* simdFloat64x2Prototype;
  244. JavascriptBoolean* booleanTrue;
  245. JavascriptBoolean* booleanFalse;
  246. Var nan;
  247. Var negativeInfinite;
  248. Var positiveInfinite;
  249. Var pi;
  250. Var minValue;
  251. Var maxValue;
  252. Var negativeZero;
  253. RecyclableObject* undefinedValue;
  254. RecyclableObject* nullValue;
  255. JavascriptSymbol* symbolHasInstance;
  256. JavascriptSymbol* symbolIsConcatSpreadable;
  257. JavascriptSymbol* symbolIterator;
  258. JavascriptSymbol* symbolSpecies;
  259. JavascriptSymbol* symbolToPrimitive;
  260. JavascriptSymbol* symbolToStringTag;
  261. JavascriptSymbol* symbolUnscopables;
  262. public:
  263. ScriptContext* scriptContext;
  264. private:
  265. virtual void Dispose(bool isShutdown) override;
  266. virtual void Finalize(bool isShutdown) override;
  267. virtual void Mark(Recycler *recycler) override { AssertMsg(false, "Mark called on object that isn't TrackableObject"); }
  268. };
  269. }