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

Side by Side Diff: include/v8.h

Issue 17068006: Remove IsInitialized checks from inlined API functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Sven Panne. Created 7 years, 6 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/api.cc » ('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 5283 matching lines...) Expand 10 before | Expand all | Expand 10 after
5294 static const int kForeignAddressOffset = kApiPointerSize; 5294 static const int kForeignAddressOffset = kApiPointerSize;
5295 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; 5295 static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
5296 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; 5296 static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
5297 static const int kContextHeaderSize = 2 * kApiPointerSize; 5297 static const int kContextHeaderSize = 2 * kApiPointerSize;
5298 static const int kContextEmbedderDataIndex = 64; 5298 static const int kContextEmbedderDataIndex = 64;
5299 static const int kFullStringRepresentationMask = 0x07; 5299 static const int kFullStringRepresentationMask = 0x07;
5300 static const int kStringEncodingMask = 0x4; 5300 static const int kStringEncodingMask = 0x4;
5301 static const int kExternalTwoByteRepresentationTag = 0x02; 5301 static const int kExternalTwoByteRepresentationTag = 0x02;
5302 static const int kExternalAsciiRepresentationTag = 0x06; 5302 static const int kExternalAsciiRepresentationTag = 0x06;
5303 5303
5304 static const int kIsolateStateOffset = 0;
5305 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; 5304 static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
5306 static const int kIsolateRootsOffset = 3 * kApiPointerSize; 5305 static const int kIsolateRootsOffset = 3 * kApiPointerSize;
5307 static const int kUndefinedValueRootIndex = 5; 5306 static const int kUndefinedValueRootIndex = 5;
5308 static const int kNullValueRootIndex = 7; 5307 static const int kNullValueRootIndex = 7;
5309 static const int kTrueValueRootIndex = 8; 5308 static const int kTrueValueRootIndex = 8;
5310 static const int kFalseValueRootIndex = 9; 5309 static const int kFalseValueRootIndex = 9;
5311 static const int kEmptyStringRootIndex = 131; 5310 static const int kEmptyStringRootIndex = 131;
5312 5311
5313 static const int kNodeClassIdOffset = 1 * kApiPointerSize; 5312 static const int kNodeClassIdOffset = 1 * kApiPointerSize;
5314 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; 5313 static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
5315 static const int kNodeStateMask = 0xf; 5314 static const int kNodeStateMask = 0xf;
5316 static const int kNodeStateIsWeakValue = 2; 5315 static const int kNodeStateIsWeakValue = 2;
5317 static const int kNodeStateIsNearDeathValue = 4; 5316 static const int kNodeStateIsNearDeathValue = 4;
5318 static const int kNodeIsIndependentShift = 4; 5317 static const int kNodeIsIndependentShift = 4;
5319 static const int kNodeIsPartiallyDependentShift = 5; 5318 static const int kNodeIsPartiallyDependentShift = 5;
5320 5319
5321 static const int kJSObjectType = 0xb0; 5320 static const int kJSObjectType = 0xb0;
5322 static const int kFirstNonstringType = 0x80; 5321 static const int kFirstNonstringType = 0x80;
5323 static const int kOddballType = 0x83; 5322 static const int kOddballType = 0x83;
5324 static const int kForeignType = 0x88; 5323 static const int kForeignType = 0x88;
5325 5324
5326 static const int kUndefinedOddballKind = 5; 5325 static const int kUndefinedOddballKind = 5;
5327 static const int kNullOddballKind = 3; 5326 static const int kNullOddballKind = 3;
5328 5327
5328 #ifdef V8_ENABLE_CHECKS
5329 static void CheckInitialized(v8::Isolate* isolate);
5330 #else
5331 static void CheckInitialized(v8::Isolate* isolate) { }
5332 #endif
5333
5329 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { 5334 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) {
5330 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == 5335 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
5331 kHeapObjectTag); 5336 kHeapObjectTag);
5332 } 5337 }
5333 5338
5334 V8_INLINE(static int SmiValue(internal::Object* value)) { 5339 V8_INLINE(static int SmiValue(internal::Object* value)) {
5335 return PlatformSmiTagging::SmiToInt(value); 5340 return PlatformSmiTagging::SmiToInt(value);
5336 } 5341 }
5337 5342
5338 V8_INLINE(static internal::Object* IntToSmi(int value)) { 5343 V8_INLINE(static internal::Object* IntToSmi(int value)) {
(...skipping 13 matching lines...) Expand all
5352 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { 5357 V8_INLINE(static int GetOddballKind(internal::Object* obj)) {
5353 typedef internal::Object O; 5358 typedef internal::Object O;
5354 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); 5359 return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
5355 } 5360 }
5356 5361
5357 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { 5362 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) {
5358 int representation = (instance_type & kFullStringRepresentationMask); 5363 int representation = (instance_type & kFullStringRepresentationMask);
5359 return representation == kExternalTwoByteRepresentationTag; 5364 return representation == kExternalTwoByteRepresentationTag;
5360 } 5365 }
5361 5366
5362 V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) {
5363 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset;
5364 return *reinterpret_cast<int*>(addr) == 1;
5365 }
5366
5367 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { 5367 V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) {
5368 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 5368 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5369 return *addr & (1 << shift); 5369 return *addr & (1 << shift);
5370 } 5370 }
5371 5371
5372 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, 5372 V8_INLINE(static void UpdateNodeFlag(internal::Object** obj,
5373 bool value, int shift)) { 5373 bool value, int shift)) {
5374 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; 5374 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
5375 uint8_t mask = 1 << shift; 5375 uint8_t mask = 1 << shift;
5376 *addr = (*addr & ~mask) | (value << shift); 5376 *addr = (*addr & ~mask) | (value << shift);
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
5932 #ifdef V8_ENABLE_CHECKS 5932 #ifdef V8_ENABLE_CHECKS
5933 CheckCast(value); 5933 CheckCast(value);
5934 #endif 5934 #endif
5935 return static_cast<String*>(value); 5935 return static_cast<String*>(value);
5936 } 5936 }
5937 5937
5938 5938
5939 Local<String> String::Empty(Isolate* isolate) { 5939 Local<String> String::Empty(Isolate* isolate) {
5940 typedef internal::Object* S; 5940 typedef internal::Object* S;
5941 typedef internal::Internals I; 5941 typedef internal::Internals I;
5942 if (!I::IsInitialized(isolate)) return Empty(); 5942 I::CheckInitialized(isolate);
5943 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); 5943 S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
5944 return Local<String>(reinterpret_cast<String*>(slot)); 5944 return Local<String>(reinterpret_cast<String*>(slot));
5945 } 5945 }
5946 5946
5947 5947
5948 Local<String> String::New(const char* data, int length) { 5948 Local<String> String::New(const char* data, int length) {
5949 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); 5949 return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length);
5950 } 5950 }
5951 5951
5952 5952
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
6285 6285
6286 template<typename T> 6286 template<typename T>
6287 ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { 6287 ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
6288 return ReturnValue<T>(&args_[kReturnValueIndex]); 6288 return ReturnValue<T>(&args_[kReturnValueIndex]);
6289 } 6289 }
6290 6290
6291 6291
6292 Handle<Primitive> Undefined(Isolate* isolate) { 6292 Handle<Primitive> Undefined(Isolate* isolate) {
6293 typedef internal::Object* S; 6293 typedef internal::Object* S;
6294 typedef internal::Internals I; 6294 typedef internal::Internals I;
6295 if (!I::IsInitialized(isolate)) return Undefined(); 6295 I::CheckInitialized(isolate);
6296 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); 6296 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
6297 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); 6297 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
6298 } 6298 }
6299 6299
6300 6300
6301 Handle<Primitive> Null(Isolate* isolate) { 6301 Handle<Primitive> Null(Isolate* isolate) {
6302 typedef internal::Object* S; 6302 typedef internal::Object* S;
6303 typedef internal::Internals I; 6303 typedef internal::Internals I;
6304 if (!I::IsInitialized(isolate)) return Null(); 6304 I::CheckInitialized(isolate);
6305 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); 6305 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
6306 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); 6306 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
6307 } 6307 }
6308 6308
6309 6309
6310 Handle<Boolean> True(Isolate* isolate) { 6310 Handle<Boolean> True(Isolate* isolate) {
6311 typedef internal::Object* S; 6311 typedef internal::Object* S;
6312 typedef internal::Internals I; 6312 typedef internal::Internals I;
6313 if (!I::IsInitialized(isolate)) return True(); 6313 I::CheckInitialized(isolate);
6314 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); 6314 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
6315 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); 6315 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
6316 } 6316 }
6317 6317
6318 6318
6319 Handle<Boolean> False(Isolate* isolate) { 6319 Handle<Boolean> False(Isolate* isolate) {
6320 typedef internal::Object* S; 6320 typedef internal::Object* S;
6321 typedef internal::Internals I; 6321 typedef internal::Internals I;
6322 if (!I::IsInitialized(isolate)) return False(); 6322 I::CheckInitialized(isolate);
6323 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); 6323 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
6324 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); 6324 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
6325 } 6325 }
6326 6326
6327 6327
6328 void Isolate::SetData(void* data) { 6328 void Isolate::SetData(void* data) {
6329 typedef internal::Internals I; 6329 typedef internal::Internals I;
6330 I::SetEmbedderData(this, data); 6330 I::SetEmbedderData(this, data);
6331 } 6331 }
6332 6332
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6372 6372
6373 6373
6374 } // namespace v8 6374 } // namespace v8
6375 6375
6376 6376
6377 #undef V8EXPORT 6377 #undef V8EXPORT
6378 #undef TYPE_CHECK 6378 #undef TYPE_CHECK
6379 6379
6380 6380
6381 #endif // V8_H_ 6381 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698