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