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

Side by Side Diff: src/api.h

Issue 173348: Api inlining. Made some core functionality available in the api and... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // Threading support for handle data. 331 // Threading support for handle data.
332 static int ArchiveSpacePerThread(); 332 static int ArchiveSpacePerThread();
333 static char* RestoreThread(char* from); 333 static char* RestoreThread(char* from);
334 static char* ArchiveThread(char* to); 334 static char* ArchiveThread(char* to);
335 335
336 // Garbage collection support. 336 // Garbage collection support.
337 static void Iterate(v8::internal::ObjectVisitor* v); 337 static void Iterate(v8::internal::ObjectVisitor* v);
338 static char* Iterate(v8::internal::ObjectVisitor* v, char* data); 338 static char* Iterate(v8::internal::ObjectVisitor* v, char* data);
339 339
340 340
341 inline void** GetSpareOrNewBlock(); 341 inline internal::Object** GetSpareOrNewBlock();
342 inline void DeleteExtensions(int extensions); 342 inline void DeleteExtensions(int extensions);
343 343
344 inline void IncrementCallDepth() {call_depth++;} 344 inline void IncrementCallDepth() {call_depth++;}
345 inline void DecrementCallDepth() {call_depth--;} 345 inline void DecrementCallDepth() {call_depth--;}
346 inline bool CallDepthIsZero() { return call_depth == 0; } 346 inline bool CallDepthIsZero() { return call_depth == 0; }
347 347
348 inline void EnterContext(Handle<Object> context); 348 inline void EnterContext(Handle<Object> context);
349 inline bool LeaveLastContext(); 349 inline bool LeaveLastContext();
350 350
351 // Returns the last entered context or an empty handle if no 351 // Returns the last entered context or an empty handle if no
352 // contexts have been entered. 352 // contexts have been entered.
353 inline Handle<Object> LastEnteredContext(); 353 inline Handle<Object> LastEnteredContext();
354 354
355 inline void SaveContext(Handle<Object> context); 355 inline void SaveContext(Handle<Object> context);
356 inline Handle<Object> RestoreContext(); 356 inline Handle<Object> RestoreContext();
357 inline bool HasSavedContexts(); 357 inline bool HasSavedContexts();
358 358
359 inline List<void**>* Blocks() { return &blocks; } 359 inline List<internal::Object**>* Blocks() { return &blocks; }
360 360
361 inline bool IgnoreOutOfMemory() { return ignore_out_of_memory; } 361 inline bool IgnoreOutOfMemory() { return ignore_out_of_memory; }
362 inline void SetIgnoreOutOfMemory(bool value) { ignore_out_of_memory = value; } 362 inline void SetIgnoreOutOfMemory(bool value) { ignore_out_of_memory = value; }
363 363
364 private: 364 private:
365 List<void**> blocks; 365 List<internal::Object**> blocks;
366 Object** spare; 366 Object** spare;
367 int call_depth; 367 int call_depth;
368 // Used as a stack to keep track of entered contexts. 368 // Used as a stack to keep track of entered contexts.
369 List<Handle<Object> > entered_contexts_; 369 List<Handle<Object> > entered_contexts_;
370 // Used as a stack to keep track of saved contexts. 370 // Used as a stack to keep track of saved contexts.
371 List<Handle<Object> > saved_contexts_; 371 List<Handle<Object> > saved_contexts_;
372 bool ignore_out_of_memory; 372 bool ignore_out_of_memory;
373 // This is only used for threading support. 373 // This is only used for threading support.
374 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; 374 v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
375 375
376 static void Iterate(ObjectVisitor* v, 376 static void Iterate(ObjectVisitor* v,
377 List<void**>* blocks, 377 List<internal::Object**>* blocks,
378 v8::ImplementationUtilities::HandleScopeData* handle_data); 378 v8::ImplementationUtilities::HandleScopeData* handle_data);
379 char* RestoreThreadHelper(char* from); 379 char* RestoreThreadHelper(char* from);
380 char* ArchiveThreadHelper(char* to); 380 char* ArchiveThreadHelper(char* to);
381 381
382 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); 382 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer);
383 }; 383 };
384 384
385 385
386 static const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page 386 static const int kHandleBlockSize = v8::internal::KB - 2; // fit in one page
387 387
(...skipping 25 matching lines...) Expand all
413 } 413 }
414 414
415 415
416 Handle<Object> HandleScopeImplementer::LastEnteredContext() { 416 Handle<Object> HandleScopeImplementer::LastEnteredContext() {
417 if (entered_contexts_.is_empty()) return Handle<Object>::null(); 417 if (entered_contexts_.is_empty()) return Handle<Object>::null();
418 return entered_contexts_.last(); 418 return entered_contexts_.last();
419 } 419 }
420 420
421 421
422 // If there's a spare block, use it for growing the current scope. 422 // If there's a spare block, use it for growing the current scope.
423 void** HandleScopeImplementer::GetSpareOrNewBlock() { 423 internal::Object** HandleScopeImplementer::GetSpareOrNewBlock() {
424 void** block = (spare != NULL) ? 424 internal::Object** block = (spare != NULL) ?
425 reinterpret_cast<void**>(spare) : 425 spare :
426 NewArray<void*>(kHandleBlockSize); 426 NewArray<internal::Object*>(kHandleBlockSize);
427 spare = NULL; 427 spare = NULL;
428 return block; 428 return block;
429 } 429 }
430 430
431 431
432 void HandleScopeImplementer::DeleteExtensions(int extensions) { 432 void HandleScopeImplementer::DeleteExtensions(int extensions) {
433 if (spare != NULL) { 433 if (spare != NULL) {
434 DeleteArray(spare); 434 DeleteArray(spare);
435 spare = NULL; 435 spare = NULL;
436 } 436 }
437 for (int i = extensions; i > 1; --i) { 437 for (int i = extensions; i > 1; --i) {
438 void** block = blocks.RemoveLast(); 438 internal::Object** block = blocks.RemoveLast();
439 #ifdef DEBUG 439 #ifdef DEBUG
440 v8::ImplementationUtilities::ZapHandleRange(block, 440 v8::ImplementationUtilities::ZapHandleRange(block,
441 &block[kHandleBlockSize]); 441 &block[kHandleBlockSize]);
442 #endif 442 #endif
443 DeleteArray(block); 443 DeleteArray(block);
444 } 444 }
445 spare = reinterpret_cast<Object**>(blocks.RemoveLast()); 445 spare = blocks.RemoveLast();
446 #ifdef DEBUG 446 #ifdef DEBUG
447 v8::ImplementationUtilities::ZapHandleRange( 447 v8::ImplementationUtilities::ZapHandleRange(
448 reinterpret_cast<void**>(spare), 448 spare,
449 reinterpret_cast<void**>(&spare[kHandleBlockSize])); 449 &spare[kHandleBlockSize]);
450 #endif 450 #endif
451 } 451 }
452 452
453 } } // namespace v8::internal 453 } } // namespace v8::internal
454 454
455 #endif // V8_API_H_ 455 #endif // V8_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698