Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: src/api-natives.cc

Issue 2201113002: [api] Fix IsSimpleInstantion check in InstantiatObject (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-inl.h" 8 #include "src/isolate-inl.h"
9 #include "src/lookup.h" 9 #include "src/lookup.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 327 }
328 328
329 bool IsSimpleInstantiation(Isolate* isolate, ObjectTemplateInfo* info, 329 bool IsSimpleInstantiation(Isolate* isolate, ObjectTemplateInfo* info,
330 JSReceiver* new_target) { 330 JSReceiver* new_target) {
331 DisallowHeapAllocation no_gc; 331 DisallowHeapAllocation no_gc;
332 332
333 if (!new_target->IsJSFunction()) return false; 333 if (!new_target->IsJSFunction()) return false;
334 JSFunction* fun = JSFunction::cast(new_target); 334 JSFunction* fun = JSFunction::cast(new_target);
335 if (fun->shared()->function_data() != info->constructor()) return false; 335 if (fun->shared()->function_data() != info->constructor()) return false;
336 if (info->immutable_proto()) return false; 336 if (info->immutable_proto()) return false;
337 return fun->context()->native_context() != 337 return fun->context()->native_context() == isolate->raw_native_context();
338 isolate->context()->native_context();
339 } 338 }
340 339
341 MaybeHandle<JSObject> InstantiateObject(Isolate* isolate, 340 MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
342 Handle<ObjectTemplateInfo> info, 341 Handle<ObjectTemplateInfo> info,
343 Handle<JSReceiver> new_target, 342 Handle<JSReceiver> new_target,
344 bool is_hidden_prototype) { 343 bool is_hidden_prototype) {
345 Handle<JSFunction> constructor; 344 Handle<JSFunction> constructor;
346 int serial_number = Smi::cast(info->serial_number())->value(); 345 int serial_number = Smi::cast(info->serial_number())->value();
347 if (!new_target.is_null()) { 346 if (!new_target.is_null()) {
348 if (IsSimpleInstantiation(isolate, *info, *new_target)) { 347 if (IsSimpleInstantiation(isolate, *info, *new_target)) {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (!obj->instance_call_handler()->IsUndefined(isolate)) { 682 if (!obj->instance_call_handler()->IsUndefined(isolate)) {
684 map->set_is_callable(); 683 map->set_is_callable();
685 map->set_is_constructor(true); 684 map->set_is_constructor(true);
686 } 685 }
687 686
688 return result; 687 return result;
689 } 688 }
690 689
691 } // namespace internal 690 } // namespace internal
692 } // namespace v8 691 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698