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

Side by Side Diff: src/api.h

Issue 7572018: Minimize malloc heap allocation on process startup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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
« 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 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // so that the currently executing thread always has its own copy of this 397 // so that the currently executing thread always has its own copy of this
398 // data. 398 // data.
399 class HandleScopeImplementer { 399 class HandleScopeImplementer {
400 public: 400 public:
401 explicit HandleScopeImplementer(Isolate* isolate) 401 explicit HandleScopeImplementer(Isolate* isolate)
402 : isolate_(isolate), 402 : isolate_(isolate),
403 blocks_(0), 403 blocks_(0),
404 entered_contexts_(0), 404 entered_contexts_(0),
405 saved_contexts_(0), 405 saved_contexts_(0),
406 spare_(NULL), 406 spare_(NULL),
407 ignore_out_of_memory_(false),
408 call_depth_(0) { } 407 call_depth_(0) { }
409 408
410 // Threading support for handle data. 409 // Threading support for handle data.
411 static int ArchiveSpacePerThread(); 410 static int ArchiveSpacePerThread();
412 char* RestoreThread(char* from); 411 char* RestoreThread(char* from);
413 char* ArchiveThread(char* to); 412 char* ArchiveThread(char* to);
414 void FreeThreadResources(); 413 void FreeThreadResources();
415 414
416 // Garbage collection support. 415 // Garbage collection support.
417 void Iterate(v8::internal::ObjectVisitor* v); 416 void Iterate(v8::internal::ObjectVisitor* v);
(...skipping 12 matching lines...) Expand all
430 429
431 // Returns the last entered context or an empty handle if no 430 // Returns the last entered context or an empty handle if no
432 // contexts have been entered. 431 // contexts have been entered.
433 inline Handle<Object> LastEnteredContext(); 432 inline Handle<Object> LastEnteredContext();
434 433
435 inline void SaveContext(Context* context); 434 inline void SaveContext(Context* context);
436 inline Context* RestoreContext(); 435 inline Context* RestoreContext();
437 inline bool HasSavedContexts(); 436 inline bool HasSavedContexts();
438 437
439 inline List<internal::Object**>* blocks() { return &blocks_; } 438 inline List<internal::Object**>* blocks() { return &blocks_; }
440 inline bool ignore_out_of_memory() { return ignore_out_of_memory_; }
441 inline void set_ignore_out_of_memory(bool value) {
442 ignore_out_of_memory_ = value;
443 }
444 439
445 private: 440 private:
446 void ResetAfterArchive() { 441 void ResetAfterArchive() {
447 blocks_.Initialize(0); 442 blocks_.Initialize(0);
448 entered_contexts_.Initialize(0); 443 entered_contexts_.Initialize(0);
449 saved_contexts_.Initialize(0); 444 saved_contexts_.Initialize(0);
450 spare_ = NULL; 445 spare_ = NULL;
451 ignore_out_of_memory_ = false;
452 call_depth_ = 0; 446 call_depth_ = 0;
453 } 447 }
454 448
455 void Free() { 449 void Free() {
456 ASSERT(blocks_.length() == 0); 450 ASSERT(blocks_.length() == 0);
457 ASSERT(entered_contexts_.length() == 0); 451 ASSERT(entered_contexts_.length() == 0);
458 ASSERT(saved_contexts_.length() == 0); 452 ASSERT(saved_contexts_.length() == 0);
459 blocks_.Free(); 453 blocks_.Free();
460 entered_contexts_.Free(); 454 entered_contexts_.Free();
461 saved_contexts_.Free(); 455 saved_contexts_.Free();
462 if (spare_ != NULL) { 456 if (spare_ != NULL) {
463 DeleteArray(spare_); 457 DeleteArray(spare_);
464 spare_ = NULL; 458 spare_ = NULL;
465 } 459 }
466 ASSERT(call_depth_ == 0); 460 ASSERT(call_depth_ == 0);
467 } 461 }
468 462
469 Isolate* isolate_; 463 Isolate* isolate_;
470 List<internal::Object**> blocks_; 464 List<internal::Object**> blocks_;
471 // Used as a stack to keep track of entered contexts. 465 // Used as a stack to keep track of entered contexts.
472 List<Handle<Object> > entered_contexts_; 466 List<Handle<Object> > entered_contexts_;
473 // Used as a stack to keep track of saved contexts. 467 // Used as a stack to keep track of saved contexts.
474 List<Context*> saved_contexts_; 468 List<Context*> saved_contexts_;
475 Object** spare_; 469 Object** spare_;
476 bool ignore_out_of_memory_;
477 int call_depth_; 470 int call_depth_;
478 // This is only used for threading support. 471 // This is only used for threading support.
479 v8::ImplementationUtilities::HandleScopeData handle_scope_data_; 472 v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
480 473
481 void IterateThis(ObjectVisitor* v); 474 void IterateThis(ObjectVisitor* v);
482 char* RestoreThreadHelper(char* from); 475 char* RestoreThreadHelper(char* from);
483 char* ArchiveThreadHelper(char* to); 476 char* ArchiveThreadHelper(char* to);
484 477
485 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer); 478 DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer);
486 }; 479 };
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 stress_type_ = stress_type; 557 stress_type_ = stress_type;
565 } 558 }
566 559
567 private: 560 private:
568 static v8::Testing::StressType stress_type_; 561 static v8::Testing::StressType stress_type_;
569 }; 562 };
570 563
571 } } // namespace v8::internal 564 } } // namespace v8::internal
572 565
573 #endif // V8_API_H_ 566 #endif // V8_API_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