OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 Handle<ExecutableAccessorInfo> Factory::NewExecutableAccessorInfo() { | 818 Handle<ExecutableAccessorInfo> Factory::NewExecutableAccessorInfo() { |
819 Handle<ExecutableAccessorInfo> info = | 819 Handle<ExecutableAccessorInfo> info = |
820 Handle<ExecutableAccessorInfo>::cast( | 820 Handle<ExecutableAccessorInfo>::cast( |
821 NewStruct(EXECUTABLE_ACCESSOR_INFO_TYPE)); | 821 NewStruct(EXECUTABLE_ACCESSOR_INFO_TYPE)); |
822 info->set_flag(0); // Must clear the flag, it was initialized as undefined. | 822 info->set_flag(0); // Must clear the flag, it was initialized as undefined. |
823 return info; | 823 return info; |
824 } | 824 } |
825 | 825 |
826 | 826 |
827 Handle<Script> Factory::NewScript(Handle<String> source) { | 827 Handle<Script> Factory::NewScript(Handle<String> source) { |
828 // Generate id for this script. | 828 // Create and initialize script object. |
829 Heap* heap = isolate()->heap(); | 829 Heap* heap = isolate()->heap(); |
830 int id = heap->last_script_id()->value() + 1; | |
831 if (!Smi::IsValid(id) || id < 0) id = 1; | |
832 heap->set_last_script_id(Smi::FromInt(id)); | |
833 | |
834 // Create and initialize script object. | |
835 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); | 830 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); |
836 script->set_source(*source); | 831 script->set_source(*source); |
837 script->set_name(heap->undefined_value()); | 832 script->set_name(heap->undefined_value()); |
838 script->set_id(Smi::FromInt(id)); | 833 script->set_id(isolate()->heap()->NextScriptId()); |
839 script->set_line_offset(Smi::FromInt(0)); | 834 script->set_line_offset(Smi::FromInt(0)); |
840 script->set_column_offset(Smi::FromInt(0)); | 835 script->set_column_offset(Smi::FromInt(0)); |
841 script->set_context_data(heap->undefined_value()); | 836 script->set_context_data(heap->undefined_value()); |
842 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); | 837 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); |
843 script->set_wrapper(heap->undefined_value()); | 838 script->set_wrapper(heap->undefined_value()); |
844 script->set_line_ends(heap->undefined_value()); | 839 script->set_line_ends(heap->undefined_value()); |
845 script->set_eval_from_shared(heap->undefined_value()); | 840 script->set_eval_from_shared(heap->undefined_value()); |
846 script->set_eval_from_instructions_offset(Smi::FromInt(0)); | 841 script->set_eval_from_instructions_offset(Smi::FromInt(0)); |
847 script->set_flags(Smi::FromInt(0)); | 842 script->set_flags(Smi::FromInt(0)); |
848 | 843 |
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 return Handle<Object>::null(); | 2316 return Handle<Object>::null(); |
2322 } | 2317 } |
2323 | 2318 |
2324 | 2319 |
2325 Handle<Object> Factory::ToBoolean(bool value) { | 2320 Handle<Object> Factory::ToBoolean(bool value) { |
2326 return value ? true_value() : false_value(); | 2321 return value ? true_value() : false_value(); |
2327 } | 2322 } |
2328 | 2323 |
2329 | 2324 |
2330 } } // namespace v8::internal | 2325 } } // namespace v8::internal |
OLD | NEW |