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

Side by Side Diff: include/v8.h

Issue 8139027: Version 3.6.5 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 2 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 | « build/standalone.gypi ('k') | include/v8-debug.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 /** 1164 /**
1165 * Get the ExternalStringResource for an external string. Returns 1165 * Get the ExternalStringResource for an external string. Returns
1166 * NULL if IsExternal() doesn't return true. 1166 * NULL if IsExternal() doesn't return true.
1167 */ 1167 */
1168 inline ExternalStringResource* GetExternalStringResource() const; 1168 inline ExternalStringResource* GetExternalStringResource() const;
1169 1169
1170 /** 1170 /**
1171 * Get the ExternalAsciiStringResource for an external ASCII string. 1171 * Get the ExternalAsciiStringResource for an external ASCII string.
1172 * Returns NULL if IsExternalAscii() doesn't return true. 1172 * Returns NULL if IsExternalAscii() doesn't return true.
1173 */ 1173 */
1174 V8EXPORT ExternalAsciiStringResource* GetExternalAsciiStringResource() const; 1174 V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResource()
1175 const;
1175 1176
1176 static inline String* Cast(v8::Value* obj); 1177 static inline String* Cast(v8::Value* obj);
1177 1178
1178 /** 1179 /**
1179 * Allocates a new string from either UTF-8 encoded or ASCII data. 1180 * Allocates a new string from either UTF-8 encoded or ASCII data.
1180 * The second parameter 'length' gives the buffer length. 1181 * The second parameter 'length' gives the buffer length.
1181 * If the data is UTF-8 encoded, the caller must 1182 * If the data is UTF-8 encoded, the caller must
1182 * be careful to supply the length parameter. 1183 * be careful to supply the length parameter.
1183 * If it is not given, the function calls 1184 * If it is not given, the function calls
1184 * 'strlen' to determine the buffer length, it might be 1185 * 'strlen' to determine the buffer length, it might be
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); 2445 static Local<TypeSwitch> New(Handle<FunctionTemplate> type);
2445 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); 2446 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
2446 int match(Handle<Value> value); 2447 int match(Handle<Value> value);
2447 private: 2448 private:
2448 TypeSwitch(); 2449 TypeSwitch();
2449 }; 2450 };
2450 2451
2451 2452
2452 // --- Extensions --- 2453 // --- Extensions ---
2453 2454
2455 class V8EXPORT ExternalAsciiStringResourceImpl
2456 : public String::ExternalAsciiStringResource {
2457 public:
2458 ExternalAsciiStringResourceImpl() : data_(0), length_(0) {}
2459 ExternalAsciiStringResourceImpl(const char* data, size_t length)
2460 : data_(data), length_(length) {}
2461 const char* data() const { return data_; }
2462 size_t length() const { return length_; }
2463
2464 private:
2465 const char* data_;
2466 size_t length_;
2467 };
2454 2468
2455 /** 2469 /**
2456 * Ignore 2470 * Ignore
2457 */ 2471 */
2458 class V8EXPORT Extension { // NOLINT 2472 class V8EXPORT Extension { // NOLINT
2459 public: 2473 public:
2474 // Note that the strings passed into this constructor must live as long
2475 // as the Extension itself.
2460 Extension(const char* name, 2476 Extension(const char* name,
2461 const char* source = 0, 2477 const char* source = 0,
2462 int dep_count = 0, 2478 int dep_count = 0,
2463 const char** deps = 0); 2479 const char** deps = 0,
2480 int source_length = -1);
2464 virtual ~Extension() { } 2481 virtual ~Extension() { }
2465 virtual v8::Handle<v8::FunctionTemplate> 2482 virtual v8::Handle<v8::FunctionTemplate>
2466 GetNativeFunction(v8::Handle<v8::String> name) { 2483 GetNativeFunction(v8::Handle<v8::String> name) {
2467 return v8::Handle<v8::FunctionTemplate>(); 2484 return v8::Handle<v8::FunctionTemplate>();
2468 } 2485 }
2469 2486
2470 const char* name() { return name_; } 2487 const char* name() const { return name_; }
2471 const char* source() { return source_; } 2488 size_t source_length() const { return source_length_; }
2489 const String::ExternalAsciiStringResource* source() const {
2490 return &source_; }
2472 int dependency_count() { return dep_count_; } 2491 int dependency_count() { return dep_count_; }
2473 const char** dependencies() { return deps_; } 2492 const char** dependencies() { return deps_; }
2474 void set_auto_enable(bool value) { auto_enable_ = value; } 2493 void set_auto_enable(bool value) { auto_enable_ = value; }
2475 bool auto_enable() { return auto_enable_; } 2494 bool auto_enable() { return auto_enable_; }
2476 2495
2477 private: 2496 private:
2478 const char* name_; 2497 const char* name_;
2479 const char* source_; 2498 size_t source_length_; // expected to initialize before source_
2499 ExternalAsciiStringResourceImpl source_;
2480 int dep_count_; 2500 int dep_count_;
2481 const char** deps_; 2501 const char** deps_;
2482 bool auto_enable_; 2502 bool auto_enable_;
2483 2503
2484 // Disallow copying and assigning. 2504 // Disallow copying and assigning.
2485 Extension(const Extension&); 2505 Extension(const Extension&);
2486 void operator=(const Extension&); 2506 void operator=(const Extension&);
2487 }; 2507 };
2488 2508
2489 2509
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
3491 * Multiple threads in V8 are allowed, but only one thread at a time 3511 * Multiple threads in V8 are allowed, but only one thread at a time
3492 * is allowed to use any given V8 isolate. See Isolate class 3512 * is allowed to use any given V8 isolate. See Isolate class
3493 * comments. The definition of 'using V8 isolate' includes 3513 * comments. The definition of 'using V8 isolate' includes
3494 * accessing handles or holding onto object pointers obtained 3514 * accessing handles or holding onto object pointers obtained
3495 * from V8 handles while in the particular V8 isolate. It is up 3515 * from V8 handles while in the particular V8 isolate. It is up
3496 * to the user of V8 to ensure (perhaps with locking) that this 3516 * to the user of V8 to ensure (perhaps with locking) that this
3497 * constraint is not violated. 3517 * constraint is not violated.
3498 * 3518 *
3499 * v8::Locker is a scoped lock object. While it's 3519 * v8::Locker is a scoped lock object. While it's
3500 * active (i.e. between its construction and destruction) the current thread is 3520 * active (i.e. between its construction and destruction) the current thread is
3501 * allowed to use the locked isolate. V8 guarantees that an isolate can be locke d 3521 * allowed to use the locked isolate. V8 guarantees that an isolate can be
3502 * by at most one thread at any time. In other words, the scope of a v8::Locker is 3522 * locked by at most one thread at any time. In other words, the scope of a
3503 * a critical section. 3523 * v8::Locker is a critical section.
3504 * 3524 *
3505 * Sample usage: 3525 * Sample usage:
3506 * \code 3526 * \code
3507 * ... 3527 * ...
3508 * { 3528 * {
3509 * v8::Locker locker(isolate); 3529 * v8::Locker locker(isolate);
3510 * v8::Isolate::Scope isolate_scope(isolate); 3530 * v8::Isolate::Scope isolate_scope(isolate);
3511 * ... 3531 * ...
3512 * // Code using V8 and isolate goes here. 3532 * // Code using V8 and isolate goes here.
3513 * ... 3533 * ...
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3595 * for the V8 lock. 3615 * for the V8 lock.
3596 */ 3616 */
3597 static void StartPreemption(int every_n_ms); 3617 static void StartPreemption(int every_n_ms);
3598 3618
3599 /** 3619 /**
3600 * Stop preemption. 3620 * Stop preemption.
3601 */ 3621 */
3602 static void StopPreemption(); 3622 static void StopPreemption();
3603 3623
3604 /** 3624 /**
3605 * Returns whether or not the locker for a given isolate, or default isolate i f NULL is given, 3625 * Returns whether or not the locker for a given isolate, or default isolate
3606 * is locked by the current thread. 3626 * if NULL is given, is locked by the current thread.
3607 */ 3627 */
3608 static bool IsLocked(Isolate* isolate = NULL); 3628 static bool IsLocked(Isolate* isolate = NULL);
3609 3629
3610 /** 3630 /**
3611 * Returns whether v8::Locker is being used by this V8 instance. 3631 * Returns whether v8::Locker is being used by this V8 instance.
3612 */ 3632 */
3613 static bool IsActive(); 3633 static bool IsActive();
3614 3634
3615 private: 3635 private:
3616 bool has_lock_; 3636 bool has_lock_;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3762 static const int kHeapObjectMapOffset = 0; 3782 static const int kHeapObjectMapOffset = 0;
3763 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; 3783 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize;
3764 static const int kStringResourceOffset = 3784 static const int kStringResourceOffset =
3765 InternalConstants<kApiPointerSize>::kStringResourceOffset; 3785 InternalConstants<kApiPointerSize>::kStringResourceOffset;
3766 3786
3767 static const int kForeignAddressOffset = kApiPointerSize; 3787 static const int kForeignAddressOffset = kApiPointerSize;
3768 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; 3788 static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
3769 static const int kFullStringRepresentationMask = 0x07; 3789 static const int kFullStringRepresentationMask = 0x07;
3770 static const int kExternalTwoByteRepresentationTag = 0x02; 3790 static const int kExternalTwoByteRepresentationTag = 0x02;
3771 3791
3772 static const int kJSObjectType = 0xa3; 3792 static const int kJSObjectType = 0xa6;
3773 static const int kFirstNonstringType = 0x80; 3793 static const int kFirstNonstringType = 0x80;
3774 static const int kForeignType = 0x85; 3794 static const int kForeignType = 0x85;
3775 3795
3776 static inline bool HasHeapObjectTag(internal::Object* value) { 3796 static inline bool HasHeapObjectTag(internal::Object* value) {
3777 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == 3797 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
3778 kHeapObjectTag); 3798 kHeapObjectTag);
3779 } 3799 }
3780 3800
3781 static inline bool HasSmiTag(internal::Object* value) { 3801 static inline bool HasSmiTag(internal::Object* value) {
3782 return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag); 3802 return ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag);
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
4201 4221
4202 4222
4203 } // namespace v8 4223 } // namespace v8
4204 4224
4205 4225
4206 #undef V8EXPORT 4226 #undef V8EXPORT
4207 #undef TYPE_CHECK 4227 #undef TYPE_CHECK
4208 4228
4209 4229
4210 #endif // V8_H_ 4230 #endif // V8_H_
OLDNEW
« no previous file with comments | « build/standalone.gypi ('k') | include/v8-debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698