Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1753)

Side by Side Diff: include/v8.h

Issue 10176004: Make static API getters inlineable again. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reorder Isolate fields to fix alignment. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2554 2554
2555 2555
2556 // --- Statics --- 2556 // --- Statics ---
2557 2557
2558 2558
2559 Handle<Primitive> V8EXPORT Undefined(); 2559 Handle<Primitive> V8EXPORT Undefined();
2560 Handle<Primitive> V8EXPORT Null(); 2560 Handle<Primitive> V8EXPORT Null();
2561 Handle<Boolean> V8EXPORT True(); 2561 Handle<Boolean> V8EXPORT True();
2562 Handle<Boolean> V8EXPORT False(); 2562 Handle<Boolean> V8EXPORT False();
2563 2563
2564 inline Handle<Primitive> Undefined(Isolate* isolate);
2565 inline Handle<Primitive> Null(Isolate* isolate);
2566 inline Handle<Boolean> True(Isolate* isolate);
2567 inline Handle<Boolean> False(Isolate* isolate);
2568
2564 2569
2565 /** 2570 /**
2566 * A set of constraints that specifies the limits of the runtime's memory use. 2571 * A set of constraints that specifies the limits of the runtime's memory use.
2567 * You must set the heap size before initializing the VM - the size cannot be 2572 * You must set the heap size before initializing the VM - the size cannot be
2568 * adjusted after the VM is initialized. 2573 * adjusted after the VM is initialized.
2569 * 2574 *
2570 * If you are using threads then you should hold the V8::Locker lock while 2575 * If you are using threads then you should hold the V8::Locker lock while
2571 * setting the stack limit and you must set a non-default stack limit separately 2576 * setting the stack limit and you must set a non-default stack limit separately
2572 * for each thread. 2577 * for each thread.
2573 */ 2578 */
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3865 kSmiTagSize + kSmiShiftSize - kPointerAlignment; 3870 kSmiTagSize + kSmiShiftSize - kPointerAlignment;
3866 }; 3871 };
3867 3872
3868 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; 3873 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
3869 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; 3874 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
3870 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; 3875 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
3871 const uintptr_t kEncodablePointerMask = 3876 const uintptr_t kEncodablePointerMask =
3872 PlatformSmiTagging::kEncodablePointerMask; 3877 PlatformSmiTagging::kEncodablePointerMask;
3873 const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift; 3878 const int kPointerToSmiShift = PlatformSmiTagging::kPointerToSmiShift;
3874 3879
3875 template <size_t ptr_size> struct InternalConstants;
3876
3877 // Internal constants for 32-bit systems.
3878 template <> struct InternalConstants<4> {
3879 static const int kStringResourceOffset = 3 * kApiPointerSize;
3880 };
3881
3882 // Internal constants for 64-bit systems.
3883 template <> struct InternalConstants<8> {
3884 static const int kStringResourceOffset = 3 * kApiPointerSize;
3885 };
3886
3887 /** 3880 /**
3888 * This class exports constants and functionality from within v8 that 3881 * This class exports constants and functionality from within v8 that
3889 * is necessary to implement inline functions in the v8 api. Don't 3882 * is necessary to implement inline functions in the v8 api. Don't
3890 * depend on functions and constants defined here. 3883 * depend on functions and constants defined here.
3891 */ 3884 */
3892 class Internals { 3885 class Internals {
3893 public: 3886 public:
3894 // These values match non-compiler-dependent values defined within 3887 // These values match non-compiler-dependent values defined within
3895 // the implementation of v8. 3888 // the implementation of v8.
3896 static const int kHeapObjectMapOffset = 0; 3889 static const int kHeapObjectMapOffset = 0;
3897 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; 3890 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize;
3898 static const int kStringResourceOffset = 3891 static const int kStringResourceOffset = 3 * kApiPointerSize;
3899 InternalConstants<kApiPointerSize>::kStringResourceOffset;
3900 3892
3901 static const int kOddballKindOffset = 3 * kApiPointerSize; 3893 static const int kOddballKindOffset = 3 * kApiPointerSize;
3902 static const int kForeignAddressOffset = kApiPointerSize; 3894 static const int kForeignAddressOffset = kApiPointerSize;
3903 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; 3895 static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
3904 static const int kFullStringRepresentationMask = 0x07; 3896 static const int kFullStringRepresentationMask = 0x07;
3905 static const int kExternalTwoByteRepresentationTag = 0x02; 3897 static const int kExternalTwoByteRepresentationTag = 0x02;
3906 3898
3899 static const int kIsolateStateOffset = 0;
3900 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
3901 static const int kIsolateRootsOffset = 3 * kApiPointerSize;
3902 static const int kUndefinedValueRootIndex = 5;
3903 static const int kNullValueRootIndex = 7;
3904 static const int kTrueValueRootIndex = 8;
3905 static const int kFalseValueRootIndex = 9;
3906
3907 static const int kJSObjectType = 0xaa; 3907 static const int kJSObjectType = 0xaa;
3908 static const int kFirstNonstringType = 0x80; 3908 static const int kFirstNonstringType = 0x80;
3909 static const int kOddballType = 0x82; 3909 static const int kOddballType = 0x82;
3910 static const int kForeignType = 0x85; 3910 static const int kForeignType = 0x85;
3911 3911
3912 static const int kUndefinedOddballKind = 5; 3912 static const int kUndefinedOddballKind = 5;
3913 static const int kNullOddballKind = 3; 3913 static const int kNullOddballKind = 3;
3914 3914
3915 static inline bool HasHeapObjectTag(internal::Object* value) { 3915 static inline bool HasHeapObjectTag(internal::Object* value) {
3916 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == 3916 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3949 } else { 3949 } else {
3950 return NULL; 3950 return NULL;
3951 } 3951 }
3952 } 3952 }
3953 3953
3954 static inline bool IsExternalTwoByteString(int instance_type) { 3954 static inline bool IsExternalTwoByteString(int instance_type) {
3955 int representation = (instance_type & kFullStringRepresentationMask); 3955 int representation = (instance_type & kFullStringRepresentationMask);
3956 return representation == kExternalTwoByteRepresentationTag; 3956 return representation == kExternalTwoByteRepresentationTag;
3957 } 3957 }
3958 3958
3959 static inline bool IsInitialized(v8::Isolate* isolate) {
3960 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset;
3961 return *reinterpret_cast<int*>(addr) == 1;
3962 }
3963
3964 static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) {
3965 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset;
3966 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize);
3967 }
3968
3959 template <typename T> 3969 template <typename T>
3960 static inline T ReadField(Object* ptr, int offset) { 3970 static inline T ReadField(Object* ptr, int offset) {
3961 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; 3971 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag;
3962 return *reinterpret_cast<T*>(addr); 3972 return *reinterpret_cast<T*>(addr);
3963 } 3973 }
3964 3974
3965 static inline bool CanCastToHeapObject(void* o) { return false; } 3975 static inline bool CanCastToHeapObject(void* o) { return false; }
3966 static inline bool CanCastToHeapObject(Context* o) { return true; } 3976 static inline bool CanCastToHeapObject(Context* o) { return true; }
3967 static inline bool CanCastToHeapObject(String* o) { return true; } 3977 static inline bool CanCastToHeapObject(String* o) { return true; }
3968 static inline bool CanCastToHeapObject(Object* o) { return true; } 3978 static inline bool CanCastToHeapObject(Object* o) { return true; }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
4371 Local<Object> AccessorInfo::This() const { 4381 Local<Object> AccessorInfo::This() const {
4372 return Local<Object>(reinterpret_cast<Object*>(&args_[0])); 4382 return Local<Object>(reinterpret_cast<Object*>(&args_[0]));
4373 } 4383 }
4374 4384
4375 4385
4376 Local<Object> AccessorInfo::Holder() const { 4386 Local<Object> AccessorInfo::Holder() const {
4377 return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); 4387 return Local<Object>(reinterpret_cast<Object*>(&args_[-1]));
4378 } 4388 }
4379 4389
4380 4390
4391 Handle<Primitive> Undefined(Isolate* isolate) {
4392 typedef internal::Object* S;
4393 typedef internal::Internals I;
4394 if (!I::IsInitialized(isolate)) return Undefined();
4395 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
4396 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
4397 }
4398
4399
4400 Handle<Primitive> Null(Isolate* isolate) {
4401 typedef internal::Object* S;
4402 typedef internal::Internals I;
4403 if (!I::IsInitialized(isolate)) return Null();
4404 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
4405 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
4406 }
4407
4408
4409 Handle<Boolean> True(Isolate* isolate) {
4410 typedef internal::Object* S;
4411 typedef internal::Internals I;
4412 if (!I::IsInitialized(isolate)) return True();
4413 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
4414 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
4415 }
4416
4417
4418 Handle<Boolean> False(Isolate* isolate) {
4419 typedef internal::Object* S;
4420 typedef internal::Internals I;
4421 if (!I::IsInitialized(isolate)) return False();
4422 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
4423 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
4424 }
4425
4426
4381 /** 4427 /**
4382 * \example shell.cc 4428 * \example shell.cc
4383 * A simple shell that takes a list of expressions on the 4429 * A simple shell that takes a list of expressions on the
4384 * command-line and executes them. 4430 * command-line and executes them.
4385 */ 4431 */
4386 4432
4387 4433
4388 /** 4434 /**
4389 * \example process.cc 4435 * \example process.cc
4390 */ 4436 */
4391 4437
4392 4438
4393 } // namespace v8 4439 } // namespace v8
4394 4440
4395 4441
4396 #undef V8EXPORT 4442 #undef V8EXPORT
4397 #undef TYPE_CHECK 4443 #undef TYPE_CHECK
4398 4444
4399 4445
4400 #endif // V8_H_ 4446 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698