| 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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 | 830 |
| 831 | 831 |
| 832 Handle<Script> Factory::NewScript(Handle<String> source) { | 832 Handle<Script> Factory::NewScript(Handle<String> source) { |
| 833 // Generate id for this script. | 833 // Generate id for this script. |
| 834 Heap* heap = isolate()->heap(); | 834 Heap* heap = isolate()->heap(); |
| 835 int id = heap->last_script_id()->value() + 1; | 835 int id = heap->last_script_id()->value() + 1; |
| 836 if (!Smi::IsValid(id) || id < 0) id = 1; | 836 if (!Smi::IsValid(id) || id < 0) id = 1; |
| 837 heap->set_last_script_id(Smi::FromInt(id)); | 837 heap->set_last_script_id(Smi::FromInt(id)); |
| 838 | 838 |
| 839 // Create and initialize script object. | 839 // Create and initialize script object. |
| 840 Handle<Foreign> wrapper = NewForeign(0, TENURED); | |
| 841 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); | 840 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE)); |
| 842 script->set_source(*source); | 841 script->set_source(*source); |
| 843 script->set_name(heap->undefined_value()); | 842 script->set_name(heap->undefined_value()); |
| 844 script->set_id(Smi::FromInt(id)); | 843 script->set_id(Smi::FromInt(id)); |
| 845 script->set_line_offset(Smi::FromInt(0)); | 844 script->set_line_offset(Smi::FromInt(0)); |
| 846 script->set_column_offset(Smi::FromInt(0)); | 845 script->set_column_offset(Smi::FromInt(0)); |
| 847 script->set_context_data(heap->undefined_value()); | 846 script->set_context_data(heap->undefined_value()); |
| 848 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); | 847 script->set_type(Smi::FromInt(Script::TYPE_NORMAL)); |
| 849 script->set_wrapper(*wrapper); | 848 script->set_wrapper(heap->undefined_value()); |
| 850 script->set_line_ends(heap->undefined_value()); | 849 script->set_line_ends(heap->undefined_value()); |
| 851 script->set_eval_from_shared(heap->undefined_value()); | 850 script->set_eval_from_shared(heap->undefined_value()); |
| 852 script->set_eval_from_instructions_offset(Smi::FromInt(0)); | 851 script->set_eval_from_instructions_offset(Smi::FromInt(0)); |
| 853 script->set_flags(Smi::FromInt(0)); | 852 script->set_flags(Smi::FromInt(0)); |
| 854 | 853 |
| 855 return script; | 854 return script; |
| 856 } | 855 } |
| 857 | 856 |
| 858 | 857 |
| 859 Handle<Foreign> Factory::NewForeign(Address addr, PretenureFlag pretenure) { | 858 Handle<Foreign> Factory::NewForeign(Address addr, PretenureFlag pretenure) { |
| (...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 return Handle<Object>::null(); | 2457 return Handle<Object>::null(); |
| 2459 } | 2458 } |
| 2460 | 2459 |
| 2461 | 2460 |
| 2462 Handle<Object> Factory::ToBoolean(bool value) { | 2461 Handle<Object> Factory::ToBoolean(bool value) { |
| 2463 return value ? true_value() : false_value(); | 2462 return value ? true_value() : false_value(); |
| 2464 } | 2463 } |
| 2465 | 2464 |
| 2466 | 2465 |
| 2467 } } // namespace v8::internal | 2466 } } // namespace v8::internal |
| OLD | NEW |