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

Side by Side Diff: src/api.cc

Issue 23464022: Add a ResourceConstraint for the embedder to specify that V8 is running on a memory constrained dev… (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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 | « include/v8.h ('k') | src/isolate.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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 return v8::Handle<Boolean>(); 617 return v8::Handle<Boolean>();
618 } 618 }
619 return ToApiHandle<Boolean>(isolate->factory()->false_value()); 619 return ToApiHandle<Boolean>(isolate->factory()->false_value());
620 } 620 }
621 621
622 622
623 ResourceConstraints::ResourceConstraints() 623 ResourceConstraints::ResourceConstraints()
624 : max_young_space_size_(0), 624 : max_young_space_size_(0),
625 max_old_space_size_(0), 625 max_old_space_size_(0),
626 max_executable_size_(0), 626 max_executable_size_(0),
627 stack_limit_(NULL) { } 627 stack_limit_(NULL),
628 is_memory_constrained_() { }
628 629
629 630
630 bool SetResourceConstraints(ResourceConstraints* constraints) { 631 bool SetResourceConstraints(ResourceConstraints* constraints) {
631 i::Isolate* isolate = EnterIsolateIfNeeded(); 632 i::Isolate* isolate = EnterIsolateIfNeeded();
632 633
633 int young_space_size = constraints->max_young_space_size(); 634 int young_space_size = constraints->max_young_space_size();
634 int old_gen_size = constraints->max_old_space_size(); 635 int old_gen_size = constraints->max_old_space_size();
635 int max_executable_size = constraints->max_executable_size(); 636 int max_executable_size = constraints->max_executable_size();
636 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { 637 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) {
637 // After initialization it's too late to change Heap constraints. 638 // After initialization it's too late to change Heap constraints.
638 ASSERT(!isolate->IsInitialized()); 639 ASSERT(!isolate->IsInitialized());
639 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, 640 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
640 old_gen_size, 641 old_gen_size,
641 max_executable_size); 642 max_executable_size);
642 if (!result) return false; 643 if (!result) return false;
643 } 644 }
644 if (constraints->stack_limit() != NULL) { 645 if (constraints->stack_limit() != NULL) {
645 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); 646 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit());
646 isolate->stack_guard()->SetStackLimit(limit); 647 isolate->stack_guard()->SetStackLimit(limit);
647 } 648 }
649 if (constraints->is_memory_constrained().has_value) {
650 isolate->set_is_memory_constrained(
651 constraints->is_memory_constrained().value);
652 }
648 return true; 653 return true;
649 } 654 }
650 655
651 656
652 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { 657 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) {
653 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; 658 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL;
654 LOG_API(isolate, "Persistent::New"); 659 LOG_API(isolate, "Persistent::New");
655 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); 660 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj);
656 #ifdef DEBUG 661 #ifdef DEBUG
657 (*obj)->Verify(); 662 (*obj)->Verify();
(...skipping 7234 matching lines...) Expand 10 before | Expand all | Expand 10 after
7892 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7897 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7893 Address callback_address = 7898 Address callback_address =
7894 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7899 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7895 VMState<EXTERNAL> state(isolate); 7900 VMState<EXTERNAL> state(isolate);
7896 ExternalCallbackScope call_scope(isolate, callback_address); 7901 ExternalCallbackScope call_scope(isolate, callback_address);
7897 callback(info); 7902 callback(info);
7898 } 7903 }
7899 7904
7900 7905
7901 } } // namespace v8::internal 7906 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698