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" | |
8 #include "src/conversions.h" | 7 #include "src/conversions.h" |
9 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
10 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
11 | 10 |
12 namespace v8 { | 11 namespace v8 { |
13 namespace internal { | 12 namespace internal { |
14 | 13 |
15 | 14 |
16 template<typename T> | 15 template<typename T> |
17 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { | 16 Handle<T> Factory::New(Handle<Map> map, AllocationSpace space) { |
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 debug_info->set_code(*code); | 2079 debug_info->set_code(*code); |
2081 debug_info->set_break_points(*break_points); | 2080 debug_info->set_break_points(*break_points); |
2082 | 2081 |
2083 // Link debug info to function. | 2082 // Link debug info to function. |
2084 shared->set_debug_info(*debug_info); | 2083 shared->set_debug_info(*debug_info); |
2085 | 2084 |
2086 return debug_info; | 2085 return debug_info; |
2087 } | 2086 } |
2088 | 2087 |
2089 | 2088 |
2090 Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee, | 2089 Handle<JSObject> Factory::NewArgumentsObject(Handle<Object> callee, |
2091 int length) { | 2090 int length) { |
2092 bool strict_mode_callee = callee->shared()->strict_mode() == STRICT; | 2091 CALL_HEAP_FUNCTION( |
2093 Handle<Map> map = strict_mode_callee ? isolate()->strict_arguments_map() | 2092 isolate(), |
2094 : isolate()->sloppy_arguments_map(); | 2093 isolate()->heap()->AllocateArgumentsObject(*callee, length), JSObject); |
2095 | |
2096 AllocationSiteUsageContext context(isolate(), Handle<AllocationSite>(), | |
2097 false); | |
2098 ASSERT(!isolate()->has_pending_exception()); | |
2099 Handle<JSObject> result = NewJSObjectFromMap(map); | |
2100 Handle<Smi> value(Smi::FromInt(length), isolate()); | |
2101 JSReceiver::SetProperty(result, length_string(), value, NONE, STRICT) | |
2102 .Assert(); | |
2103 if (!strict_mode_callee) { | |
2104 JSReceiver::SetProperty(result, callee_string(), callee, NONE, STRICT) | |
2105 .Assert(); | |
2106 } | |
2107 return result; | |
2108 } | 2094 } |
2109 | 2095 |
2110 | 2096 |
2111 Handle<JSFunction> Factory::CreateApiFunction( | 2097 Handle<JSFunction> Factory::CreateApiFunction( |
2112 Handle<FunctionTemplateInfo> obj, | 2098 Handle<FunctionTemplateInfo> obj, |
2113 Handle<Object> prototype, | 2099 Handle<Object> prototype, |
2114 ApiInstanceType instance_type) { | 2100 ApiInstanceType instance_type) { |
2115 Handle<Code> code = isolate()->builtins()->HandleApiCall(); | 2101 Handle<Code> code = isolate()->builtins()->HandleApiCall(); |
2116 Handle<Code> construct_stub = isolate()->builtins()->JSConstructStubApi(); | 2102 Handle<Code> construct_stub = isolate()->builtins()->JSConstructStubApi(); |
2117 | 2103 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 return Handle<Object>::null(); | 2367 return Handle<Object>::null(); |
2382 } | 2368 } |
2383 | 2369 |
2384 | 2370 |
2385 Handle<Object> Factory::ToBoolean(bool value) { | 2371 Handle<Object> Factory::ToBoolean(bool value) { |
2386 return value ? true_value() : false_value(); | 2372 return value ? true_value() : false_value(); |
2387 } | 2373 } |
2388 | 2374 |
2389 | 2375 |
2390 } } // namespace v8::internal | 2376 } } // namespace v8::internal |
OLD | NEW |