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 #ifndef V8_FACTORY_H_ | 5 #ifndef V8_FACTORY_H_ |
6 #define V8_FACTORY_H_ | 6 #define V8_FACTORY_H_ |
7 | 7 |
8 #include "isolate.h" | 8 #include "isolate.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 Handle<JSGeneratorObject> NewJSGeneratorObject(Handle<JSFunction> function); | 381 Handle<JSGeneratorObject> NewJSGeneratorObject(Handle<JSFunction> function); |
382 | 382 |
383 Handle<JSArrayBuffer> NewJSArrayBuffer(); | 383 Handle<JSArrayBuffer> NewJSArrayBuffer(); |
384 | 384 |
385 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type); | 385 Handle<JSTypedArray> NewJSTypedArray(ExternalArrayType type); |
386 | 386 |
387 Handle<JSDataView> NewJSDataView(); | 387 Handle<JSDataView> NewJSDataView(); |
388 | 388 |
389 Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype); | 389 Handle<JSProxy> NewJSProxy(Handle<Object> handler, Handle<Object> prototype); |
390 | 390 |
391 // Reinitialize a JSReceiver into an (empty) JS object of respective type and | |
392 // size, but keeping the original prototype. The receiver must have at least | |
393 // the size of the new object. The object is reinitialized and behaves as an | |
394 // object that has been freshly allocated. | |
395 void ReinitializeJSReceiver( | |
396 Handle<JSReceiver> object, InstanceType type, int size); | |
397 | |
398 // Reinitialize an JSGlobalProxy based on a constructor. The object | |
399 // must have the same size as objects allocated using the | |
400 // constructor. The object is reinitialized and behaves as an | |
401 // object that has been freshly allocated using the constructor. | |
402 void ReinitializeJSGlobalProxy( | |
403 Handle<JSFunction> constructor, Handle<JSGlobalProxy> global); | |
Michael Starzinger
2014/04/15 09:54:59
suggestion: I know it was like this before your ch
Igor Sheludko
2014/04/15 11:03:42
I agree, done.
| |
404 | |
391 // Change the type of the argument into a JS object/function and reinitialize. | 405 // Change the type of the argument into a JS object/function and reinitialize. |
392 void BecomeJSObject(Handle<JSReceiver> object); | 406 void BecomeJSObject(Handle<JSReceiver> object); |
393 void BecomeJSFunction(Handle<JSReceiver> object); | 407 void BecomeJSFunction(Handle<JSReceiver> object); |
394 | 408 |
395 Handle<JSFunction> NewFunction(Handle<String> name, | 409 Handle<JSFunction> NewFunction(Handle<String> name, |
396 Handle<Object> prototype); | 410 Handle<Object> prototype); |
397 | 411 |
398 Handle<JSFunction> NewFunctionWithoutPrototype( | |
Igor Sheludko
2014/04/15 08:33:32
moved declaration down
| |
399 Handle<String> name, | |
400 StrictMode strict_mode); | |
401 | |
402 Handle<JSFunction> NewFunction(Handle<Object> super, bool is_global); | |
Igor Sheludko
2014/04/15 08:33:32
declaration only
| |
403 | |
404 Handle<JSFunction> BaseNewFunctionFromSharedFunctionInfo( | |
Igor Sheludko
2014/04/15 08:33:32
one usage - inlined
| |
405 Handle<SharedFunctionInfo> function_info, | |
406 Handle<Map> function_map, | |
407 PretenureFlag pretenure); | |
408 | |
409 Handle<JSFunction> NewFunctionFromSharedFunctionInfo( | 412 Handle<JSFunction> NewFunctionFromSharedFunctionInfo( |
410 Handle<SharedFunctionInfo> function_info, | 413 Handle<SharedFunctionInfo> function_info, |
411 Handle<Context> context, | 414 Handle<Context> context, |
412 PretenureFlag pretenure = TENURED); | 415 PretenureFlag pretenure = TENURED); |
413 | 416 |
417 Handle<JSFunction> NewFunction(Handle<String> name, | |
418 InstanceType type, | |
419 int instance_size, | |
420 Handle<Code> code, | |
421 bool force_initial_map); | |
422 | |
423 Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name, | |
424 InstanceType type, | |
425 int instance_size, | |
426 Handle<JSObject> prototype, | |
427 Handle<Code> code, | |
428 bool force_initial_map); | |
429 | |
430 Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, | |
431 StrictMode strict_mode); | |
432 | |
433 Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, | |
434 Handle<Code> code); | |
435 | |
414 // Create a serialized scope info. | 436 // Create a serialized scope info. |
415 Handle<ScopeInfo> NewScopeInfo(int length); | 437 Handle<ScopeInfo> NewScopeInfo(int length); |
416 | 438 |
417 // Create an External object for V8's external API. | 439 // Create an External object for V8's external API. |
418 Handle<JSObject> NewExternal(void* value); | 440 Handle<JSObject> NewExternal(void* value); |
419 | 441 |
420 Handle<Code> NewCode(const CodeDesc& desc, | 442 Handle<Code> NewCode(const CodeDesc& desc, |
421 Code::Flags flags, | 443 Code::Flags flags, |
422 Handle<Object> self_reference, | 444 Handle<Object> self_reference, |
423 bool immovable = false, | 445 bool immovable = false, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 | 481 |
460 Handle<Object> NewReferenceError(const char* message, | 482 Handle<Object> NewReferenceError(const char* message, |
461 Vector< Handle<Object> > args); | 483 Vector< Handle<Object> > args); |
462 Handle<Object> NewReferenceError(const char* message, Handle<JSArray> args); | 484 Handle<Object> NewReferenceError(const char* message, Handle<JSArray> args); |
463 Handle<Object> NewReferenceError(Handle<String> message); | 485 Handle<Object> NewReferenceError(Handle<String> message); |
464 | 486 |
465 Handle<Object> NewEvalError(const char* message, | 487 Handle<Object> NewEvalError(const char* message, |
466 Vector< Handle<Object> > args); | 488 Vector< Handle<Object> > args); |
467 | 489 |
468 | 490 |
469 Handle<JSFunction> NewFunction(Handle<String> name, | |
Igor Sheludko
2014/04/15 08:33:32
Moved these declarations up
| |
470 InstanceType type, | |
471 int instance_size, | |
472 Handle<Code> code, | |
473 bool force_initial_map); | |
474 | |
475 Handle<JSFunction> NewFunction(Handle<Map> function_map, | |
Igor Sheludko
2014/04/15 08:33:32
declaration only
| |
476 Handle<SharedFunctionInfo> shared, Handle<Object> prototype); | |
477 | |
478 | |
479 Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name, | |
480 InstanceType type, | |
481 int instance_size, | |
482 Handle<JSObject> prototype, | |
483 Handle<Code> code, | |
484 bool force_initial_map); | |
485 | |
486 Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name, | |
487 Handle<Code> code); | |
488 | |
489 Handle<String> NumberToString(Handle<Object> number); | 491 Handle<String> NumberToString(Handle<Object> number); |
490 Handle<String> Uint32ToString(uint32_t value); | 492 Handle<String> Uint32ToString(uint32_t value); |
491 | 493 |
492 enum ApiInstanceType { | 494 enum ApiInstanceType { |
493 JavaScriptObject, | 495 JavaScriptObject, |
494 InnerGlobalObject, | 496 InnerGlobalObject, |
495 OuterGlobalObject | 497 OuterGlobalObject |
496 }; | 498 }; |
497 | 499 |
498 Handle<JSFunction> CreateApiFunction( | 500 Handle<JSFunction> CreateApiFunction( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 // object which is neither configurable nor writable) like 'undefined'. | 592 // object which is neither configurable nor writable) like 'undefined'. |
591 // Returns a null handle when the given name is unknown. | 593 // Returns a null handle when the given name is unknown. |
592 Handle<Object> GlobalConstantFor(Handle<String> name); | 594 Handle<Object> GlobalConstantFor(Handle<String> name); |
593 | 595 |
594 // Converts the given boolean condition to JavaScript boolean value. | 596 // Converts the given boolean condition to JavaScript boolean value. |
595 Handle<Object> ToBoolean(bool value); | 597 Handle<Object> ToBoolean(bool value); |
596 | 598 |
597 private: | 599 private: |
598 Isolate* isolate() { return reinterpret_cast<Isolate*>(this); } | 600 Isolate* isolate() { return reinterpret_cast<Isolate*>(this); } |
599 | 601 |
600 Handle<JSFunction> NewFunctionHelper(Handle<String> name, | 602 // Creates a heap object based on the map. |
Michael Starzinger
2014/04/15 09:54:59
nit: Can we add one sentence saying that the field
Igor Sheludko
2014/04/15 11:03:42
Done.
| |
601 Handle<Object> prototype); | 603 template<typename T> |
604 Handle<T> New(Handle<Map> map, AllocationSpace space); | |
602 | 605 |
603 Handle<JSFunction> NewFunctionWithoutPrototypeHelper( | 606 template<typename T> |
604 Handle<String> name, | 607 Handle<T> New(Handle<Map> map, |
605 StrictMode strict_mode); | 608 AllocationSpace space, |
609 Handle<AllocationSite> allocation_site); | |
610 | |
611 // Initializes a function with a shared part and prototype. | |
612 // Note: this code was factored out of NewFunctionHelper such that | |
613 // other parts of the VM could use it. Specifically, a function that creates | |
614 // instances of type JS_FUNCTION_TYPE benefit from the use of this function. | |
615 inline void InitializeFunction(Handle<JSFunction> function, | |
616 Handle<SharedFunctionInfo> shared, | |
617 Handle<Object> prototype); | |
618 | |
619 // Creates a function initialized with a shared part. | |
620 inline Handle<JSFunction> NewFunctionHelper( | |
621 Handle<Map> function_map, | |
622 Handle<SharedFunctionInfo> shared, | |
623 Handle<Object> prototype, | |
624 PretenureFlag pretenure = TENURED); | |
606 | 625 |
607 // Create a new map cache. | 626 // Create a new map cache. |
608 Handle<MapCache> NewMapCache(int at_least_space_for); | 627 Handle<MapCache> NewMapCache(int at_least_space_for); |
609 | 628 |
610 // Update the map cache in the native context with (keys, map) | 629 // Update the map cache in the native context with (keys, map) |
611 Handle<MapCache> AddToMapCache(Handle<Context> context, | 630 Handle<MapCache> AddToMapCache(Handle<Context> context, |
612 Handle<FixedArray> keys, | 631 Handle<FixedArray> keys, |
613 Handle<Map> map); | 632 Handle<Map> map); |
614 }; | 633 }; |
615 | 634 |
616 } } // namespace v8::internal | 635 } } // namespace v8::internal |
617 | 636 |
618 #endif // V8_FACTORY_H_ | 637 #endif // V8_FACTORY_H_ |
OLD | NEW |