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