OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 V(JSModule) \ | 801 V(JSModule) \ |
802 V(Map) \ | 802 V(Map) \ |
803 V(DescriptorArray) \ | 803 V(DescriptorArray) \ |
804 V(TransitionArray) \ | 804 V(TransitionArray) \ |
805 V(DeoptimizationInputData) \ | 805 V(DeoptimizationInputData) \ |
806 V(DeoptimizationOutputData) \ | 806 V(DeoptimizationOutputData) \ |
807 V(TypeFeedbackCells) \ | 807 V(TypeFeedbackCells) \ |
808 V(FixedArray) \ | 808 V(FixedArray) \ |
809 V(FixedDoubleArray) \ | 809 V(FixedDoubleArray) \ |
810 V(Context) \ | 810 V(Context) \ |
811 V(GlobalContext) \ | 811 V(NativeContext) \ |
812 V(ModuleContext) \ | 812 V(ModuleContext) \ |
813 V(ScopeInfo) \ | 813 V(ScopeInfo) \ |
814 V(JSFunction) \ | 814 V(JSFunction) \ |
815 V(Code) \ | 815 V(Code) \ |
816 V(Oddball) \ | 816 V(Oddball) \ |
817 V(SharedFunctionInfo) \ | 817 V(SharedFunctionInfo) \ |
818 V(JSValue) \ | 818 V(JSValue) \ |
819 V(JSDate) \ | 819 V(JSDate) \ |
820 V(JSMessageObject) \ | 820 V(JSMessageObject) \ |
821 V(StringWrapper) \ | 821 V(StringWrapper) \ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 // Returns true if the object is of the correct type to be used as a | 898 // Returns true if the object is of the correct type to be used as a |
899 // implementation of a JSObject's elements. | 899 // implementation of a JSObject's elements. |
900 inline bool HasValidElements(); | 900 inline bool HasValidElements(); |
901 | 901 |
902 inline bool HasSpecificClassOf(String* name); | 902 inline bool HasSpecificClassOf(String* name); |
903 | 903 |
904 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. | 904 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. |
905 Object* ToBoolean(); // ECMA-262 9.2. | 905 Object* ToBoolean(); // ECMA-262 9.2. |
906 | 906 |
907 // Convert to a JSObject if needed. | 907 // Convert to a JSObject if needed. |
908 // global_context is used when creating wrapper object. | 908 // native_context is used when creating wrapper object. |
909 MUST_USE_RESULT MaybeObject* ToObject(Context* global_context); | 909 MUST_USE_RESULT MaybeObject* ToObject(Context* native_context); |
910 | 910 |
911 // Converts this to a Smi if possible. | 911 // Converts this to a Smi if possible. |
912 // Failure is returned otherwise. | 912 // Failure is returned otherwise. |
913 MUST_USE_RESULT inline MaybeObject* ToSmi(); | 913 MUST_USE_RESULT inline MaybeObject* ToSmi(); |
914 | 914 |
915 void Lookup(String* name, LookupResult* result); | 915 void Lookup(String* name, LookupResult* result); |
916 | 916 |
917 // Property access. | 917 // Property access. |
918 MUST_USE_RESULT inline MaybeObject* GetProperty(String* key); | 918 MUST_USE_RESULT inline MaybeObject* GetProperty(String* key); |
919 MUST_USE_RESULT inline MaybeObject* GetProperty( | 919 MUST_USE_RESULT inline MaybeObject* GetProperty( |
(...skipping 4394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5314 // SharedFunctionInfo describes the JSFunction information that can be | 5314 // SharedFunctionInfo describes the JSFunction information that can be |
5315 // shared by multiple instances of the function. | 5315 // shared by multiple instances of the function. |
5316 class SharedFunctionInfo: public HeapObject { | 5316 class SharedFunctionInfo: public HeapObject { |
5317 public: | 5317 public: |
5318 // [name]: Function name. | 5318 // [name]: Function name. |
5319 DECL_ACCESSORS(name, Object) | 5319 DECL_ACCESSORS(name, Object) |
5320 | 5320 |
5321 // [code]: Function code. | 5321 // [code]: Function code. |
5322 DECL_ACCESSORS(code, Code) | 5322 DECL_ACCESSORS(code, Code) |
5323 | 5323 |
5324 // [optimized_code_map]: Map from global context to optimized code | 5324 // [optimized_code_map]: Map from native context to optimized code |
5325 // and a shared literals array or Smi 0 if none. | 5325 // and a shared literals array or Smi 0 if none. |
5326 DECL_ACCESSORS(optimized_code_map, Object) | 5326 DECL_ACCESSORS(optimized_code_map, Object) |
5327 | 5327 |
5328 // Returns index i of the entry with the specified context. At position | 5328 // Returns index i of the entry with the specified context. At position |
5329 // i - 1 is the context, position i the code, and i + 1 the literals array. | 5329 // i - 1 is the context, position i the code, and i + 1 the literals array. |
5330 // Returns -1 when no matching entry is found. | 5330 // Returns -1 when no matching entry is found. |
5331 int SearchOptimizedCodeMap(Context* global_context); | 5331 int SearchOptimizedCodeMap(Context* native_context); |
5332 | 5332 |
5333 // Installs optimized code from the code map on the given closure. The | 5333 // Installs optimized code from the code map on the given closure. The |
5334 // index has to be consistent with a search result as defined above. | 5334 // index has to be consistent with a search result as defined above. |
5335 void InstallFromOptimizedCodeMap(JSFunction* function, int index); | 5335 void InstallFromOptimizedCodeMap(JSFunction* function, int index); |
5336 | 5336 |
5337 // Clear optimized code map. | 5337 // Clear optimized code map. |
5338 void ClearOptimizedCodeMap(); | 5338 void ClearOptimizedCodeMap(); |
5339 | 5339 |
5340 // Add a new entry to the optimized code map. | 5340 // Add a new entry to the optimized code map. |
5341 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 5341 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
5342 Handle<Context> global_context, | 5342 Handle<Context> native_context, |
5343 Handle<Code> code, | 5343 Handle<Code> code, |
5344 Handle<FixedArray> literals); | 5344 Handle<FixedArray> literals); |
5345 static const int kEntryLength = 3; | 5345 static const int kEntryLength = 3; |
5346 | 5346 |
5347 // [scope_info]: Scope info. | 5347 // [scope_info]: Scope info. |
5348 DECL_ACCESSORS(scope_info, ScopeInfo) | 5348 DECL_ACCESSORS(scope_info, ScopeInfo) |
5349 | 5349 |
5350 // [construct stub]: Code stub for constructing instances of this function. | 5350 // [construct stub]: Code stub for constructing instances of this function. |
5351 DECL_ACCESSORS(construct_stub, Code) | 5351 DECL_ACCESSORS(construct_stub, Code) |
5352 | 5352 |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6115 } | 6115 } |
6116 void JSFunctionPrint(FILE* out); | 6116 void JSFunctionPrint(FILE* out); |
6117 #endif | 6117 #endif |
6118 #ifdef DEBUG | 6118 #ifdef DEBUG |
6119 void JSFunctionVerify(); | 6119 void JSFunctionVerify(); |
6120 #endif | 6120 #endif |
6121 | 6121 |
6122 // Returns the number of allocated literals. | 6122 // Returns the number of allocated literals. |
6123 inline int NumberOfLiterals(); | 6123 inline int NumberOfLiterals(); |
6124 | 6124 |
6125 // Retrieve the global context from a function's literal array. | 6125 // Retrieve the native context from a function's literal array. |
6126 static Context* GlobalContextFromLiterals(FixedArray* literals); | 6126 static Context* NativeContextFromLiterals(FixedArray* literals); |
6127 | 6127 |
6128 // Layout descriptors. The last property (from kNonWeakFieldsEndOffset to | 6128 // Layout descriptors. The last property (from kNonWeakFieldsEndOffset to |
6129 // kSize) is weak and has special handling during garbage collection. | 6129 // kSize) is weak and has special handling during garbage collection. |
6130 static const int kCodeEntryOffset = JSObject::kHeaderSize; | 6130 static const int kCodeEntryOffset = JSObject::kHeaderSize; |
6131 static const int kPrototypeOrInitialMapOffset = | 6131 static const int kPrototypeOrInitialMapOffset = |
6132 kCodeEntryOffset + kPointerSize; | 6132 kCodeEntryOffset + kPointerSize; |
6133 static const int kSharedFunctionInfoOffset = | 6133 static const int kSharedFunctionInfoOffset = |
6134 kPrototypeOrInitialMapOffset + kPointerSize; | 6134 kPrototypeOrInitialMapOffset + kPointerSize; |
6135 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize; | 6135 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize; |
6136 static const int kLiteralsOffset = kContextOffset + kPointerSize; | 6136 static const int kLiteralsOffset = kContextOffset + kPointerSize; |
6137 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize; | 6137 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize; |
6138 static const int kNextFunctionLinkOffset = kNonWeakFieldsEndOffset; | 6138 static const int kNextFunctionLinkOffset = kNonWeakFieldsEndOffset; |
6139 static const int kSize = kNextFunctionLinkOffset + kPointerSize; | 6139 static const int kSize = kNextFunctionLinkOffset + kPointerSize; |
6140 | 6140 |
6141 // Layout of the literals array. | 6141 // Layout of the literals array. |
6142 static const int kLiteralsPrefixSize = 1; | 6142 static const int kLiteralsPrefixSize = 1; |
6143 static const int kLiteralGlobalContextIndex = 0; | 6143 static const int kLiteralNativeContextIndex = 0; |
6144 | 6144 |
6145 // Layout of the bound-function binding array. | 6145 // Layout of the bound-function binding array. |
6146 static const int kBoundFunctionIndex = 0; | 6146 static const int kBoundFunctionIndex = 0; |
6147 static const int kBoundThisIndex = 1; | 6147 static const int kBoundThisIndex = 1; |
6148 static const int kBoundArgumentsStartIndex = 2; | 6148 static const int kBoundArgumentsStartIndex = 2; |
6149 | 6149 |
6150 private: | 6150 private: |
6151 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); | 6151 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); |
6152 }; | 6152 }; |
6153 | 6153 |
6154 | 6154 |
6155 // JSGlobalProxy's prototype must be a JSGlobalObject or null, | 6155 // JSGlobalProxy's prototype must be a JSGlobalObject or null, |
6156 // and the prototype is hidden. JSGlobalProxy always delegates | 6156 // and the prototype is hidden. JSGlobalProxy always delegates |
6157 // property accesses to its prototype if the prototype is not null. | 6157 // property accesses to its prototype if the prototype is not null. |
6158 // | 6158 // |
6159 // A JSGlobalProxy can be reinitialized which will preserve its identity. | 6159 // A JSGlobalProxy can be reinitialized which will preserve its identity. |
6160 // | 6160 // |
6161 // Accessing a JSGlobalProxy requires security check. | 6161 // Accessing a JSGlobalProxy requires security check. |
6162 | 6162 |
6163 class JSGlobalProxy : public JSObject { | 6163 class JSGlobalProxy : public JSObject { |
6164 public: | 6164 public: |
6165 // [context]: the owner global context of this global proxy object. | 6165 // [context]: the owner native context of this global proxy object. |
6166 // It is null value if this object is not used by any context. | 6166 // It is null value if this object is not used by any context. |
6167 DECL_ACCESSORS(context, Object) | 6167 DECL_ACCESSORS(context, Object) |
6168 | 6168 |
6169 // Casting. | 6169 // Casting. |
6170 static inline JSGlobalProxy* cast(Object* obj); | 6170 static inline JSGlobalProxy* cast(Object* obj); |
6171 | 6171 |
6172 // Dispatched behavior. | 6172 // Dispatched behavior. |
6173 #ifdef OBJECT_PRINT | 6173 #ifdef OBJECT_PRINT |
6174 inline void JSGlobalProxyPrint() { | 6174 inline void JSGlobalProxyPrint() { |
6175 JSGlobalProxyPrint(stdout); | 6175 JSGlobalProxyPrint(stdout); |
(...skipping 16 matching lines...) Expand all Loading... |
6192 // Forward declaration. | 6192 // Forward declaration. |
6193 class JSBuiltinsObject; | 6193 class JSBuiltinsObject; |
6194 | 6194 |
6195 // Common super class for JavaScript global objects and the special | 6195 // Common super class for JavaScript global objects and the special |
6196 // builtins global objects. | 6196 // builtins global objects. |
6197 class GlobalObject: public JSObject { | 6197 class GlobalObject: public JSObject { |
6198 public: | 6198 public: |
6199 // [builtins]: the object holding the runtime routines written in JS. | 6199 // [builtins]: the object holding the runtime routines written in JS. |
6200 DECL_ACCESSORS(builtins, JSBuiltinsObject) | 6200 DECL_ACCESSORS(builtins, JSBuiltinsObject) |
6201 | 6201 |
6202 // [global context]: the global context corresponding to this global object. | 6202 // [native context]: the natives corresponding to this global object. |
6203 DECL_ACCESSORS(global_context, Context) | 6203 DECL_ACCESSORS(native_context, Context) |
6204 | 6204 |
6205 // [global receiver]: the global receiver object of the context | 6205 // [global receiver]: the global receiver object of the context |
6206 DECL_ACCESSORS(global_receiver, JSObject) | 6206 DECL_ACCESSORS(global_receiver, JSObject) |
6207 | 6207 |
6208 // Retrieve the property cell used to store a property. | 6208 // Retrieve the property cell used to store a property. |
6209 JSGlobalPropertyCell* GetPropertyCell(LookupResult* result); | 6209 JSGlobalPropertyCell* GetPropertyCell(LookupResult* result); |
6210 | 6210 |
6211 // This is like GetProperty, but is used when you know the lookup won't fail | 6211 // This is like GetProperty, but is used when you know the lookup won't fail |
6212 // by throwing an exception. This is for the debug and builtins global | 6212 // by throwing an exception. This is for the debug and builtins global |
6213 // objects, where it is known which properties can be expected to be present | 6213 // objects, where it is known which properties can be expected to be present |
6214 // on the object. | 6214 // on the object. |
6215 Object* GetPropertyNoExceptionThrown(String* key) { | 6215 Object* GetPropertyNoExceptionThrown(String* key) { |
6216 Object* answer = GetProperty(key)->ToObjectUnchecked(); | 6216 Object* answer = GetProperty(key)->ToObjectUnchecked(); |
6217 return answer; | 6217 return answer; |
6218 } | 6218 } |
6219 | 6219 |
6220 // Ensure that the global object has a cell for the given property name. | 6220 // Ensure that the global object has a cell for the given property name. |
6221 static Handle<JSGlobalPropertyCell> EnsurePropertyCell( | 6221 static Handle<JSGlobalPropertyCell> EnsurePropertyCell( |
6222 Handle<GlobalObject> global, | 6222 Handle<GlobalObject> global, |
6223 Handle<String> name); | 6223 Handle<String> name); |
6224 // TODO(kmillikin): This function can be eliminated once the stub cache is | 6224 // TODO(kmillikin): This function can be eliminated once the stub cache is |
6225 // full handlified (and the static helper can be written directly). | 6225 // full handlified (and the static helper can be written directly). |
6226 MUST_USE_RESULT MaybeObject* EnsurePropertyCell(String* name); | 6226 MUST_USE_RESULT MaybeObject* EnsurePropertyCell(String* name); |
6227 | 6227 |
6228 // Casting. | 6228 // Casting. |
6229 static inline GlobalObject* cast(Object* obj); | 6229 static inline GlobalObject* cast(Object* obj); |
6230 | 6230 |
6231 // Layout description. | 6231 // Layout description. |
6232 static const int kBuiltinsOffset = JSObject::kHeaderSize; | 6232 static const int kBuiltinsOffset = JSObject::kHeaderSize; |
6233 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize; | 6233 static const int kNativeContextOffset = kBuiltinsOffset + kPointerSize; |
6234 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; | 6234 static const int kGlobalReceiverOffset = kNativeContextOffset + kPointerSize; |
6235 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; | 6235 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; |
6236 | 6236 |
6237 private: | 6237 private: |
6238 DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject); | 6238 DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject); |
6239 }; | 6239 }; |
6240 | 6240 |
6241 | 6241 |
6242 // JavaScript global object. | 6242 // JavaScript global object. |
6243 class JSGlobalObject: public GlobalObject { | 6243 class JSGlobalObject: public GlobalObject { |
6244 public: | 6244 public: |
(...skipping 2670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8915 } else { | 8915 } else { |
8916 value &= ~(1 << bit_position); | 8916 value &= ~(1 << bit_position); |
8917 } | 8917 } |
8918 return value; | 8918 return value; |
8919 } | 8919 } |
8920 }; | 8920 }; |
8921 | 8921 |
8922 } } // namespace v8::internal | 8922 } } // namespace v8::internal |
8923 | 8923 |
8924 #endif // V8_OBJECTS_H_ | 8924 #endif // V8_OBJECTS_H_ |
OLD | NEW |