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

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

Issue 2108203002: Implement immutable prototype chains (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: simplify Created 4 years, 5 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 | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | src/objects.cc » ('J')
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 Handle<JSReceiver> new_target, 297 Handle<JSReceiver> new_target,
298 bool is_hidden_prototype) { 298 bool is_hidden_prototype) {
299 Handle<JSFunction> constructor; 299 Handle<JSFunction> constructor;
300 uint32_t serial_number = 300 uint32_t serial_number =
301 static_cast<uint32_t>(Smi::cast(info->serial_number())->value()); 301 static_cast<uint32_t>(Smi::cast(info->serial_number())->value());
302 if (!new_target.is_null()) { 302 if (!new_target.is_null()) {
303 if (new_target->IsJSFunction() && 303 if (new_target->IsJSFunction() &&
304 JSFunction::cast(*new_target)->shared()->function_data() == 304 JSFunction::cast(*new_target)->shared()->function_data() ==
305 info->constructor() && 305 info->constructor() &&
306 JSFunction::cast(*new_target)->context()->native_context() == 306 JSFunction::cast(*new_target)->context()->native_context() ==
307 isolate->context()->native_context()) { 307 isolate->context()->native_context() &&
308 !info->immutable_proto()) {
308 constructor = Handle<JSFunction>::cast(new_target); 309 constructor = Handle<JSFunction>::cast(new_target);
309 } else { 310 } else {
310 // Disable caching for subclass instantiation. 311 // Disable caching for subclass instantiation.
311 serial_number = 0; 312 serial_number = 0;
312 } 313 }
313 } 314 }
314 // Fast path. 315 // Fast path.
315 Handle<JSObject> result; 316 Handle<JSObject> result;
316 if (serial_number) { 317 if (serial_number) {
317 // Probe cache. 318 // Probe cache.
(...skipping 21 matching lines...) Expand all
339 340
340 if (new_target.is_null()) new_target = constructor; 341 if (new_target.is_null()) new_target = constructor;
341 } 342 }
342 343
343 Handle<JSObject> object; 344 Handle<JSObject> object;
344 ASSIGN_RETURN_ON_EXCEPTION(isolate, object, 345 ASSIGN_RETURN_ON_EXCEPTION(isolate, object,
345 JSObject::New(constructor, new_target), JSObject); 346 JSObject::New(constructor, new_target), JSObject);
346 ASSIGN_RETURN_ON_EXCEPTION( 347 ASSIGN_RETURN_ON_EXCEPTION(
347 isolate, result, 348 isolate, result,
348 ConfigureInstance(isolate, object, info, is_hidden_prototype), JSObject); 349 ConfigureInstance(isolate, object, info, is_hidden_prototype), JSObject);
350 if (info->immutable_proto()) {
351 MAYBE_RETURN(JSObject::SetImmutableProto(
Toon Verwaest 2016/06/30 15:35:33 I don't think we need to walk the hidden prototype
Dan Ehrenberg 2016/06/30 23:12:41 Removed all that extra useless code.
352 object, false, Object::ShouldThrow::THROW_ON_ERROR),
353 MaybeHandle<JSObject>());
354 }
349 // TODO(dcarney): is this necessary? 355 // TODO(dcarney): is this necessary?
350 JSObject::MigrateSlowToFast(result, 0, "ApiNatives::InstantiateObject"); 356 JSObject::MigrateSlowToFast(result, 0, "ApiNatives::InstantiateObject");
351 357
352 if (serial_number) { 358 if (serial_number) {
353 CacheTemplateInstantiation(isolate, serial_number, result); 359 CacheTemplateInstantiation(isolate, serial_number, result);
354 result = isolate->factory()->CopyJSObject(result); 360 result = isolate->factory()->CopyJSObject(result);
355 } 361 }
356 return scope.CloseAndEscape(result); 362 return scope.CloseAndEscape(result);
357 } 363 }
358 364
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } else { 571 } else {
566 JSObject::AddProperty(Handle<JSObject>::cast(prototype), 572 JSObject::AddProperty(Handle<JSObject>::cast(prototype),
567 isolate->factory()->constructor_string(), result, 573 isolate->factory()->constructor_string(), result,
568 DONT_ENUM); 574 DONT_ENUM);
569 } 575 }
570 576
571 int internal_field_count = 0; 577 int internal_field_count = 0;
572 if (!obj->instance_template()->IsUndefined(isolate)) { 578 if (!obj->instance_template()->IsUndefined(isolate)) {
573 Handle<ObjectTemplateInfo> instance_template = Handle<ObjectTemplateInfo>( 579 Handle<ObjectTemplateInfo> instance_template = Handle<ObjectTemplateInfo>(
574 ObjectTemplateInfo::cast(obj->instance_template())); 580 ObjectTemplateInfo::cast(obj->instance_template()));
575 internal_field_count = 581 internal_field_count = instance_template->internal_field_count();
576 Smi::cast(instance_template->internal_field_count())->value();
577 } 582 }
578 583
579 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing 584 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing
580 // JSObject::GetHeaderSize. 585 // JSObject::GetHeaderSize.
581 int instance_size = kPointerSize * internal_field_count; 586 int instance_size = kPointerSize * internal_field_count;
582 InstanceType type; 587 InstanceType type;
583 switch (instance_type) { 588 switch (instance_type) {
584 case JavaScriptObjectType: 589 case JavaScriptObjectType:
585 if (!obj->needs_access_check() && 590 if (!obj->needs_access_check() &&
586 obj->named_property_handler()->IsUndefined(isolate) && 591 obj->named_property_handler()->IsUndefined(isolate) &&
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 if (!obj->instance_call_handler()->IsUndefined(isolate)) { 636 if (!obj->instance_call_handler()->IsUndefined(isolate)) {
632 map->set_is_callable(); 637 map->set_is_callable();
633 map->set_is_constructor(true); 638 map->set_is_constructor(true);
634 } 639 }
635 640
636 return result; 641 return result;
637 } 642 }
638 643
639 } // namespace internal 644 } // namespace internal
640 } // namespace v8 645 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698