OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/api-natives.h" | 5 #include "src/api-natives.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/lookup.h" | 9 #include "src/lookup.h" |
10 | 10 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if (constructor->IsUndefined()) { | 198 if (constructor->IsUndefined()) { |
199 cons = isolate->object_function(); | 199 cons = isolate->object_function(); |
200 } else { | 200 } else { |
201 auto cons_templ = Handle<FunctionTemplateInfo>::cast(constructor); | 201 auto cons_templ = Handle<FunctionTemplateInfo>::cast(constructor); |
202 ASSIGN_RETURN_ON_EXCEPTION( | 202 ASSIGN_RETURN_ON_EXCEPTION( |
203 isolate, cons, InstantiateFunction(isolate, cons_templ), JSFunction); | 203 isolate, cons, InstantiateFunction(isolate, cons_templ), JSFunction); |
204 } | 204 } |
205 auto object = isolate->factory()->NewJSObject(cons); | 205 auto object = isolate->factory()->NewJSObject(cons); |
206 ASSIGN_RETURN_ON_EXCEPTION( | 206 ASSIGN_RETURN_ON_EXCEPTION( |
207 isolate, result, ConfigureInstance(isolate, object, info), JSFunction); | 207 isolate, result, ConfigureInstance(isolate, object, info), JSFunction); |
208 if (!constructor->IsUndefined()) { | |
209 RETURN_ON_EXCEPTION( | |
210 isolate, Execution::Call(isolate, cons, result, 0, nullptr), JSObject); | |
211 } | |
212 // TODO(dcarney): is this necessary? | 208 // TODO(dcarney): is this necessary? |
213 JSObject::MigrateSlowToFast(result, 0, "ApiNatives::InstantiateObject"); | 209 JSObject::MigrateSlowToFast(result, 0, "ApiNatives::InstantiateObject"); |
214 return scope.CloseAndEscape(result); | 210 return scope.CloseAndEscape(result); |
215 } | 211 } |
216 | 212 |
217 | 213 |
218 void CacheFunction(Isolate* isolate, Handle<Smi> serial_number, | 214 void CacheFunction(Isolate* isolate, Handle<Smi> serial_number, |
219 Handle<JSFunction> function) { | 215 Handle<JSFunction> function) { |
220 auto cache = isolate->function_cache(); | 216 auto cache = isolate->function_cache(); |
221 auto new_cache = ObjectHashTable::Put(cache, serial_number, function); | 217 auto new_cache = ObjectHashTable::Put(cache, serial_number, function); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); | 579 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); |
584 JSObject::SetAccessor(result, accessor).Assert(); | 580 JSObject::SetAccessor(result, accessor).Assert(); |
585 } | 581 } |
586 | 582 |
587 DCHECK(result->shared()->IsApiFunction()); | 583 DCHECK(result->shared()->IsApiFunction()); |
588 return result; | 584 return result; |
589 } | 585 } |
590 | 586 |
591 } // namespace internal | 587 } // namespace internal |
592 } // namespace v8 | 588 } // namespace v8 |
OLD | NEW |