| 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 function->shared()->set_native(true); | 375 function->shared()->set_native(true); |
| 376 return function; | 376 return function; |
| 377 } | 377 } |
| 378 | 378 |
| 379 | 379 |
| 380 void Genesis::SetFunctionInstanceDescriptor( | 380 void Genesis::SetFunctionInstanceDescriptor( |
| 381 Handle<Map> map, FunctionMode function_mode) { | 381 Handle<Map> map, FunctionMode function_mode) { |
| 382 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4; | 382 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4; |
| 383 Map::EnsureDescriptorSlack(map, size); | 383 Map::EnsureDescriptorSlack(map, size); |
| 384 | 384 |
| 385 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 385 PropertyAttributes ro_attribs = |
| 386 DONT_ENUM | DONT_DELETE | READ_ONLY); | 386 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 387 PropertyAttributes roc_attribs = |
| 388 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); |
| 387 | 389 |
| 388 Handle<AccessorInfo> length = | 390 Handle<AccessorInfo> length = |
| 389 Accessors::FunctionLengthInfo(isolate(), attribs); | 391 Accessors::FunctionLengthInfo(isolate(), ro_attribs); |
| 390 { // Add length. | 392 { // Add length. |
| 391 AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())), | 393 AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())), |
| 392 length, attribs); | 394 length, ro_attribs); |
| 393 map->AppendDescriptor(&d); | 395 map->AppendDescriptor(&d); |
| 394 } | 396 } |
| 395 Handle<AccessorInfo> name = | 397 Handle<AccessorInfo> name = |
| 396 Accessors::FunctionNameInfo(isolate(), attribs); | 398 Accessors::FunctionNameInfo(isolate(), ro_attribs); |
| 397 { // Add name. | 399 { // Add name. |
| 398 AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name, | 400 AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name, |
| 399 attribs); | 401 roc_attribs); |
| 400 map->AppendDescriptor(&d); | 402 map->AppendDescriptor(&d); |
| 401 } | 403 } |
| 402 Handle<AccessorInfo> args = | 404 Handle<AccessorInfo> args = |
| 403 Accessors::FunctionArgumentsInfo(isolate(), attribs); | 405 Accessors::FunctionArgumentsInfo(isolate(), ro_attribs); |
| 404 { // Add arguments. | 406 { // Add arguments. |
| 405 AccessorConstantDescriptor d(Handle<Name>(Name::cast(args->name())), args, | 407 AccessorConstantDescriptor d(Handle<Name>(Name::cast(args->name())), args, |
| 406 attribs); | 408 ro_attribs); |
| 407 map->AppendDescriptor(&d); | 409 map->AppendDescriptor(&d); |
| 408 } | 410 } |
| 409 Handle<AccessorInfo> caller = | 411 Handle<AccessorInfo> caller = |
| 410 Accessors::FunctionCallerInfo(isolate(), attribs); | 412 Accessors::FunctionCallerInfo(isolate(), ro_attribs); |
| 411 { // Add caller. | 413 { // Add caller. |
| 412 AccessorConstantDescriptor d(Handle<Name>(Name::cast(caller->name())), | 414 AccessorConstantDescriptor d(Handle<Name>(Name::cast(caller->name())), |
| 413 caller, attribs); | 415 caller, ro_attribs); |
| 414 map->AppendDescriptor(&d); | 416 map->AppendDescriptor(&d); |
| 415 } | 417 } |
| 416 if (IsFunctionModeWithPrototype(function_mode)) { | 418 if (IsFunctionModeWithPrototype(function_mode)) { |
| 417 if (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE) { | 419 if (function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE) { |
| 418 attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY); | 420 ro_attribs = static_cast<PropertyAttributes>(ro_attribs & ~READ_ONLY); |
| 419 } | 421 } |
| 420 Handle<AccessorInfo> prototype = | 422 Handle<AccessorInfo> prototype = |
| 421 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 423 Accessors::FunctionPrototypeInfo(isolate(), ro_attribs); |
| 422 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 424 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
| 423 prototype, attribs); | 425 prototype, ro_attribs); |
| 424 map->AppendDescriptor(&d); | 426 map->AppendDescriptor(&d); |
| 425 } | 427 } |
| 426 } | 428 } |
| 427 | 429 |
| 428 | 430 |
| 429 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { | 431 Handle<Map> Genesis::CreateSloppyFunctionMap(FunctionMode function_mode) { |
| 430 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); | 432 Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); |
| 431 SetFunctionInstanceDescriptor(map, function_mode); | 433 SetFunctionInstanceDescriptor(map, function_mode); |
| 432 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); | 434 map->set_function_with_prototype(IsFunctionModeWithPrototype(function_mode)); |
| 433 return map; | 435 return map; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 Handle<Map> map, FunctionMode function_mode) { | 535 Handle<Map> map, FunctionMode function_mode) { |
| 534 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4; | 536 int size = IsFunctionModeWithPrototype(function_mode) ? 5 : 4; |
| 535 Map::EnsureDescriptorSlack(map, size); | 537 Map::EnsureDescriptorSlack(map, size); |
| 536 | 538 |
| 537 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); | 539 Handle<AccessorPair> arguments(factory()->NewAccessorPair()); |
| 538 Handle<AccessorPair> caller(factory()->NewAccessorPair()); | 540 Handle<AccessorPair> caller(factory()->NewAccessorPair()); |
| 539 PropertyAttributes rw_attribs = | 541 PropertyAttributes rw_attribs = |
| 540 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 542 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| 541 PropertyAttributes ro_attribs = | 543 PropertyAttributes ro_attribs = |
| 542 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 544 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 545 PropertyAttributes roc_attribs = |
| 546 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); |
| 543 | 547 |
| 544 // Add length. | 548 // Add length. |
| 545 if (function_mode == BOUND_FUNCTION) { | 549 if (function_mode == BOUND_FUNCTION) { |
| 546 Handle<String> length_string = isolate()->factory()->length_string(); | 550 Handle<String> length_string = isolate()->factory()->length_string(); |
| 547 DataDescriptor d(length_string, 0, ro_attribs, Representation::Tagged()); | 551 DataDescriptor d(length_string, 0, ro_attribs, Representation::Tagged()); |
| 548 map->AppendDescriptor(&d); | 552 map->AppendDescriptor(&d); |
| 549 } else { | 553 } else { |
| 550 DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE || | 554 DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE || |
| 551 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE || | 555 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE || |
| 552 function_mode == FUNCTION_WITHOUT_PROTOTYPE); | 556 function_mode == FUNCTION_WITHOUT_PROTOTYPE); |
| 553 Handle<AccessorInfo> length = | 557 Handle<AccessorInfo> length = |
| 554 Accessors::FunctionLengthInfo(isolate(), ro_attribs); | 558 Accessors::FunctionLengthInfo(isolate(), ro_attribs); |
| 555 AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())), | 559 AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())), |
| 556 length, ro_attribs); | 560 length, ro_attribs); |
| 557 map->AppendDescriptor(&d); | 561 map->AppendDescriptor(&d); |
| 558 } | 562 } |
| 559 Handle<AccessorInfo> name = | 563 Handle<AccessorInfo> name = |
| 560 Accessors::FunctionNameInfo(isolate(), ro_attribs); | 564 Accessors::FunctionNameInfo(isolate(), roc_attribs); |
| 561 { // Add name. | 565 { // Add name. |
| 562 AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name, | 566 AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name, |
| 563 ro_attribs); | 567 roc_attribs); |
| 564 map->AppendDescriptor(&d); | 568 map->AppendDescriptor(&d); |
| 565 } | 569 } |
| 566 { // Add arguments. | 570 { // Add arguments. |
| 567 AccessorConstantDescriptor d(factory()->arguments_string(), arguments, | 571 AccessorConstantDescriptor d(factory()->arguments_string(), arguments, |
| 568 rw_attribs); | 572 rw_attribs); |
| 569 map->AppendDescriptor(&d); | 573 map->AppendDescriptor(&d); |
| 570 } | 574 } |
| 571 { // Add caller. | 575 { // Add caller. |
| 572 AccessorConstantDescriptor d(factory()->caller_string(), caller, | 576 AccessorConstantDescriptor d(factory()->caller_string(), caller, |
| 573 rw_attribs); | 577 rw_attribs); |
| (...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 return from + sizeof(NestingCounterType); | 2920 return from + sizeof(NestingCounterType); |
| 2917 } | 2921 } |
| 2918 | 2922 |
| 2919 | 2923 |
| 2920 // Called when the top-level V8 mutex is destroyed. | 2924 // Called when the top-level V8 mutex is destroyed. |
| 2921 void Bootstrapper::FreeThreadResources() { | 2925 void Bootstrapper::FreeThreadResources() { |
| 2922 DCHECK(!IsActive()); | 2926 DCHECK(!IsActive()); |
| 2923 } | 2927 } |
| 2924 | 2928 |
| 2925 } } // namespace v8::internal | 2929 } } // namespace v8::internal |
| OLD | NEW |