OLD | NEW |
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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 return v8::Handle<Boolean>(); | 613 return v8::Handle<Boolean>(); |
614 } | 614 } |
615 return ToApiHandle<Boolean>(isolate->factory()->false_value()); | 615 return ToApiHandle<Boolean>(isolate->factory()->false_value()); |
616 } | 616 } |
617 | 617 |
618 | 618 |
619 ResourceConstraints::ResourceConstraints() | 619 ResourceConstraints::ResourceConstraints() |
620 : max_young_space_size_(0), | 620 : max_young_space_size_(0), |
621 max_old_space_size_(0), | 621 max_old_space_size_(0), |
622 max_executable_size_(0), | 622 max_executable_size_(0), |
623 stack_limit_(NULL) { } | 623 stack_limit_(NULL), |
| 624 is_memory_constrained_(false) { } |
624 | 625 |
625 | 626 |
626 bool SetResourceConstraints(ResourceConstraints* constraints) { | 627 bool SetResourceConstraints(ResourceConstraints* constraints) { |
627 i::Isolate* isolate = EnterIsolateIfNeeded(); | 628 i::Isolate* isolate = EnterIsolateIfNeeded(); |
628 | 629 |
629 int young_space_size = constraints->max_young_space_size(); | 630 int young_space_size = constraints->max_young_space_size(); |
630 int old_gen_size = constraints->max_old_space_size(); | 631 int old_gen_size = constraints->max_old_space_size(); |
631 int max_executable_size = constraints->max_executable_size(); | 632 int max_executable_size = constraints->max_executable_size(); |
632 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { | 633 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { |
633 // After initialization it's too late to change Heap constraints. | 634 // After initialization it's too late to change Heap constraints. |
634 ASSERT(!isolate->IsInitialized()); | 635 ASSERT(!isolate->IsInitialized()); |
635 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 636 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, |
636 old_gen_size, | 637 old_gen_size, |
637 max_executable_size); | 638 max_executable_size); |
638 if (!result) return false; | 639 if (!result) return false; |
639 } | 640 } |
640 if (constraints->stack_limit() != NULL) { | 641 if (constraints->stack_limit() != NULL) { |
641 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 642 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
642 isolate->stack_guard()->SetStackLimit(limit); | 643 isolate->stack_guard()->SetStackLimit(limit); |
643 } | 644 } |
| 645 isolate->setIsMemoryConstrained(constraints->is_memory_constrained()); |
644 return true; | 646 return true; |
645 } | 647 } |
646 | 648 |
647 | 649 |
648 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 650 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
649 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; | 651 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; |
650 LOG_API(isolate, "Persistent::New"); | 652 LOG_API(isolate, "Persistent::New"); |
651 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 653 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
652 #ifdef DEBUG | 654 #ifdef DEBUG |
653 (*obj)->Verify(); | 655 (*obj)->Verify(); |
(...skipping 7444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8098 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8100 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8099 Address callback_address = | 8101 Address callback_address = |
8100 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8102 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8101 VMState<EXTERNAL> state(isolate); | 8103 VMState<EXTERNAL> state(isolate); |
8102 ExternalCallbackScope call_scope(isolate, callback_address); | 8104 ExternalCallbackScope call_scope(isolate, callback_address); |
8103 return callback(info); | 8105 return callback(info); |
8104 } | 8106 } |
8105 | 8107 |
8106 | 8108 |
8107 } } // namespace v8::internal | 8109 } } // namespace v8::internal |
OLD | NEW |