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

Side by Side Diff: src/bootstrapper.cc

Issue 246693005: Convert function.prototype to API-style accessor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Check that exception is never thrown Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/accessors.cc ('k') | 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 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 "bootstrapper.h" 5 #include "bootstrapper.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "natives.h" 9 #include "natives.h"
10 #include "snapshot.h" 10 #include "snapshot.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 void Genesis::SetFunctionInstanceDescriptor( 386 void Genesis::SetFunctionInstanceDescriptor(
387 Handle<Map> map, PrototypePropertyMode prototypeMode) { 387 Handle<Map> map, PrototypePropertyMode prototypeMode) {
388 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 388 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
389 Map::EnsureDescriptorSlack(map, size); 389 Map::EnsureDescriptorSlack(map, size);
390 390
391 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 391 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
392 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 392 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
393 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments)); 393 Handle<Foreign> args(factory()->NewForeign(&Accessors::FunctionArguments));
394 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller)); 394 Handle<Foreign> caller(factory()->NewForeign(&Accessors::FunctionCaller));
395 Handle<Foreign> prototype;
396 if (prototypeMode != DONT_ADD_PROTOTYPE) {
397 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
398 }
399 PropertyAttributes attribs = static_cast<PropertyAttributes>( 395 PropertyAttributes attribs = static_cast<PropertyAttributes>(
400 DONT_ENUM | DONT_DELETE | READ_ONLY); 396 DONT_ENUM | DONT_DELETE | READ_ONLY);
401 397
402 { // Add length. 398 { // Add length.
403 CallbacksDescriptor d(factory()->length_string(), length, attribs); 399 CallbacksDescriptor d(factory()->length_string(), length, attribs);
404 map->AppendDescriptor(&d); 400 map->AppendDescriptor(&d);
405 } 401 }
406 { // Add name. 402 { // Add name.
407 CallbacksDescriptor d(factory()->name_string(), name, attribs); 403 CallbacksDescriptor d(factory()->name_string(), name, attribs);
408 map->AppendDescriptor(&d); 404 map->AppendDescriptor(&d);
409 } 405 }
410 { // Add arguments. 406 { // Add arguments.
411 CallbacksDescriptor d(factory()->arguments_string(), args, attribs); 407 CallbacksDescriptor d(factory()->arguments_string(), args, attribs);
412 map->AppendDescriptor(&d); 408 map->AppendDescriptor(&d);
413 } 409 }
414 { // Add caller. 410 { // Add caller.
415 CallbacksDescriptor d(factory()->caller_string(), caller, attribs); 411 CallbacksDescriptor d(factory()->caller_string(), caller, attribs);
416 map->AppendDescriptor(&d); 412 map->AppendDescriptor(&d);
417 } 413 }
418 if (prototypeMode != DONT_ADD_PROTOTYPE) { 414 if (prototypeMode != DONT_ADD_PROTOTYPE) {
419 // Add prototype.
420 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { 415 if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
421 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); 416 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY);
422 } 417 }
423 CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs); 418 Handle<AccessorInfo> prototype =
419 Accessors::FunctionPrototypeInfo(isolate(), attribs);
420 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())),
421 prototype, attribs);
424 map->AppendDescriptor(&d); 422 map->AppendDescriptor(&d);
425 } 423 }
426 } 424 }
427 425
428 426
429 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { 427 Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
430 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); 428 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
431 SetFunctionInstanceDescriptor(map, prototype_mode); 429 SetFunctionInstanceDescriptor(map, prototype_mode);
432 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE); 430 map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
433 return map; 431 return map;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 514
517 void Genesis::SetStrictFunctionInstanceDescriptor( 515 void Genesis::SetStrictFunctionInstanceDescriptor(
518 Handle<Map> map, PrototypePropertyMode prototypeMode) { 516 Handle<Map> map, PrototypePropertyMode prototypeMode) {
519 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; 517 int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5;
520 Map::EnsureDescriptorSlack(map, size); 518 Map::EnsureDescriptorSlack(map, size);
521 519
522 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength)); 520 Handle<Foreign> length(factory()->NewForeign(&Accessors::FunctionLength));
523 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName)); 521 Handle<Foreign> name(factory()->NewForeign(&Accessors::FunctionName));
524 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); 522 Handle<AccessorPair> arguments(factory()->NewAccessorPair());
525 Handle<AccessorPair> caller(factory()->NewAccessorPair()); 523 Handle<AccessorPair> caller(factory()->NewAccessorPair());
526 Handle<Foreign> prototype;
527 if (prototypeMode != DONT_ADD_PROTOTYPE) {
528 prototype = factory()->NewForeign(&Accessors::FunctionPrototype);
529 }
530 PropertyAttributes rw_attribs = 524 PropertyAttributes rw_attribs =
531 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 525 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
532 PropertyAttributes ro_attribs = 526 PropertyAttributes ro_attribs =
533 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 527 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
534 528
535 { // Add length. 529 { // Add length.
536 CallbacksDescriptor d(factory()->length_string(), length, ro_attribs); 530 CallbacksDescriptor d(factory()->length_string(), length, ro_attribs);
537 map->AppendDescriptor(&d); 531 map->AppendDescriptor(&d);
538 } 532 }
539 { // Add name. 533 { // Add name.
540 CallbacksDescriptor d(factory()->name_string(), name, ro_attribs); 534 CallbacksDescriptor d(factory()->name_string(), name, ro_attribs);
541 map->AppendDescriptor(&d); 535 map->AppendDescriptor(&d);
542 } 536 }
543 { // Add arguments. 537 { // Add arguments.
544 CallbacksDescriptor d(factory()->arguments_string(), arguments, 538 CallbacksDescriptor d(factory()->arguments_string(), arguments,
545 rw_attribs); 539 rw_attribs);
546 map->AppendDescriptor(&d); 540 map->AppendDescriptor(&d);
547 } 541 }
548 { // Add caller. 542 { // Add caller.
549 CallbacksDescriptor d(factory()->caller_string(), caller, rw_attribs); 543 CallbacksDescriptor d(factory()->caller_string(), caller, rw_attribs);
550 map->AppendDescriptor(&d); 544 map->AppendDescriptor(&d);
551 } 545 }
552 if (prototypeMode != DONT_ADD_PROTOTYPE) { 546 if (prototypeMode != DONT_ADD_PROTOTYPE) {
553 // Add prototype. 547 // Add prototype.
554 PropertyAttributes attribs = 548 PropertyAttributes attribs =
555 prototypeMode == ADD_WRITEABLE_PROTOTYPE ? rw_attribs : ro_attribs; 549 prototypeMode == ADD_WRITEABLE_PROTOTYPE ? rw_attribs : ro_attribs;
556 CallbacksDescriptor d(factory()->prototype_string(), prototype, attribs); 550 Handle<AccessorInfo> prototype =
551 Accessors::FunctionPrototypeInfo(isolate(), attribs);
552 CallbacksDescriptor d(Handle<Name>(Name::cast(prototype->name())),
553 prototype, attribs);
557 map->AppendDescriptor(&d); 554 map->AppendDescriptor(&d);
558 } 555 }
559 } 556 }
560 557
561 558
562 // ECMAScript 5th Edition, 13.2.3 559 // ECMAScript 5th Edition, 13.2.3
563 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() { 560 Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
564 if (throw_type_error_function.is_null()) { 561 if (throw_type_error_function.is_null()) {
565 Handle<String> name = factory()->InternalizeOneByteString( 562 Handle<String> name = factory()->InternalizeOneByteString(
566 STATIC_ASCII_VECTOR("ThrowTypeError")); 563 STATIC_ASCII_VECTOR("ThrowTypeError"));
(...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 return from + sizeof(NestingCounterType); 2679 return from + sizeof(NestingCounterType);
2683 } 2680 }
2684 2681
2685 2682
2686 // Called when the top-level V8 mutex is destroyed. 2683 // Called when the top-level V8 mutex is destroyed.
2687 void Bootstrapper::FreeThreadResources() { 2684 void Bootstrapper::FreeThreadResources() {
2688 ASSERT(!IsActive()); 2685 ASSERT(!IsActive());
2689 } 2686 }
2690 2687
2691 } } // namespace v8::internal 2688 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698