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

Side by Side Diff: src/bootstrapper.cc

Issue 2158303002: Begin porting CallSite to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@remove-overflow-boilerplate
Patch Set: Eager CallSite import and rebase 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 | « BUILD.gn ('k') | src/builtins/builtins.h » ('j') | 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 "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/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } else { 427 } else {
428 fun->shared()->DontAdaptArguments(); 428 fun->shared()->DontAdaptArguments();
429 } 429 }
430 fun->shared()->set_length(len); 430 fun->shared()->set_length(len);
431 return fun; 431 return fun;
432 } 432 }
433 433
434 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base, 434 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base,
435 Handle<String> name, 435 Handle<String> name,
436 Builtins::Name call, int len, 436 Builtins::Name call, int len,
437 bool adapt) { 437 bool adapt,
438 PropertyAttributes attrs = DONT_ENUM) {
438 Handle<JSFunction> fun = 439 Handle<JSFunction> fun =
439 SimpleCreateFunction(base->GetIsolate(), name, call, len, adapt); 440 SimpleCreateFunction(base->GetIsolate(), name, call, len, adapt);
440 InstallFunction(base, fun, name, DONT_ENUM); 441 InstallFunction(base, fun, name, attrs);
441 return fun; 442 return fun;
442 } 443 }
443 444
444 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base, 445 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base,
445 const char* name, Builtins::Name call, 446 const char* name, Builtins::Name call,
446 int len, bool adapt) { 447 int len, bool adapt,
448 PropertyAttributes attrs = DONT_ENUM) {
447 Factory* const factory = base->GetIsolate()->factory(); 449 Factory* const factory = base->GetIsolate()->factory();
448 return SimpleInstallFunction(base, factory->InternalizeUtf8String(name), call, 450 return SimpleInstallFunction(base, factory->InternalizeUtf8String(name), call,
449 len, adapt); 451 len, adapt, attrs);
450 } 452 }
451 453
452 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base, 454 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
453 Handle<String> name, Builtins::Name call, 455 Handle<String> name, Builtins::Name call,
454 bool adapt) { 456 bool adapt) {
455 Isolate* const isolate = base->GetIsolate(); 457 Isolate* const isolate = base->GetIsolate();
456 Handle<String> fun_name = 458 Handle<String> fun_name =
457 Name::ToFunctionName(name, isolate->factory()->get_string()) 459 Name::ToFunctionName(name, isolate->factory()->get_string())
458 .ToHandleChecked(); 460 .ToHandleChecked();
459 Handle<JSFunction> fun = 461 Handle<JSFunction> fun =
(...skipping 2165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 Handle<JSFunction> async_function_next = 2627 Handle<JSFunction> async_function_next =
2626 SimpleInstallFunction(container, "AsyncFunctionNext", 2628 SimpleInstallFunction(container, "AsyncFunctionNext",
2627 Builtins::kGeneratorPrototypeNext, 1, true); 2629 Builtins::kGeneratorPrototypeNext, 1, true);
2628 Handle<JSFunction> async_function_throw = 2630 Handle<JSFunction> async_function_throw =
2629 SimpleInstallFunction(container, "AsyncFunctionThrow", 2631 SimpleInstallFunction(container, "AsyncFunctionThrow",
2630 Builtins::kGeneratorPrototypeThrow, 1, true); 2632 Builtins::kGeneratorPrototypeThrow, 1, true);
2631 async_function_next->shared()->set_native(false); 2633 async_function_next->shared()->set_native(false);
2632 async_function_throw->shared()->set_native(false); 2634 async_function_throw->shared()->set_native(false);
2633 } 2635 }
2634 } 2636 }
2637
2638 { // -- C a l l S i t e
2639 // Builtin functions for CallSite.
2640
2641 Handle<JSFunction> callsite_fun = InstallFunction(
2642 container, "CallSite", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2643 isolate->initial_object_prototype(), Builtins::kCallSiteConstructor);
2644 callsite_fun->shared()->DontAdaptArguments();
2645 callsite_fun->shared()->set_native(true);
2646
2647 {
2648 Handle<JSObject> proto =
2649 factory->NewJSObject(isolate->object_function(), TENURED);
2650 JSObject::AddProperty(proto, factory->constructor_string(), callsite_fun,
2651 DONT_ENUM);
2652
2653 struct FunctionInfo {
2654 const char* name;
2655 Builtins::Name id;
2656 };
2657
2658 FunctionInfo infos[] = {
2659 {"getColumnNumber", Builtins::kCallSitePrototypeGetColumnNumber},
2660 {"getEvalOrigin", Builtins::kCallSitePrototypeGetEvalOrigin},
2661 {"getFileName", Builtins::kCallSitePrototypeGetFileName},
2662 {"getFunction", Builtins::kCallSitePrototypeGetFunction},
2663 {"getFunctionName", Builtins::kCallSitePrototypeGetFunctionName},
2664 {"getLineNumber", Builtins::kCallSitePrototypeGetLineNumber},
2665 {"getMethodName", Builtins::kCallSitePrototypeGetMethodName},
2666 {"getPosition", Builtins::kCallSitePrototypeGetPosition},
2667 {"getScriptNameOrSourceURL",
2668 Builtins::kCallSitePrototypeGetScriptNameOrSourceURL},
2669 {"getThis", Builtins::kCallSitePrototypeGetThis},
2670 {"getTypeName", Builtins::kCallSitePrototypeGetTypeName},
2671 {"isConstructor", Builtins::kCallSitePrototypeIsConstructor},
2672 {"isEval", Builtins::kCallSitePrototypeIsEval},
2673 {"isNative", Builtins::kCallSitePrototypeIsNative},
2674 {"isToplevel", Builtins::kCallSitePrototypeIsToplevel}};
2675
2676 PropertyAttributes attrs =
2677 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
2678
2679 Handle<JSFunction> fun;
2680 for (const FunctionInfo& info : infos) {
2681 fun = SimpleInstallFunction(proto, info.name, info.id, 0, true, attrs);
2682 fun->shared()->set_native(true);
2683 }
2684
2685 Accessors::FunctionSetPrototype(callsite_fun, proto).Assert();
2686 }
2687 }
2635 } 2688 }
2636 2689
2637 2690
2638 void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate, 2691 void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
2639 Handle<JSObject> container) { 2692 Handle<JSObject> container) {
2640 HandleScope scope(isolate); 2693 HandleScope scope(isolate);
2641 2694
2642 #define INITIALIZE_FLAG(FLAG) \ 2695 #define INITIALIZE_FLAG(FLAG) \
2643 { \ 2696 { \
2644 Handle<String> name = \ 2697 Handle<String> name = \
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
3995 } 4048 }
3996 4049
3997 4050
3998 // Called when the top-level V8 mutex is destroyed. 4051 // Called when the top-level V8 mutex is destroyed.
3999 void Bootstrapper::FreeThreadResources() { 4052 void Bootstrapper::FreeThreadResources() {
4000 DCHECK(!IsActive()); 4053 DCHECK(!IsActive());
4001 } 4054 }
4002 4055
4003 } // namespace internal 4056 } // namespace internal
4004 } // namespace v8 4057 } // namespace v8
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/builtins/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698