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

Side by Side Diff: src/bootstrapper.cc

Issue 2551763003: v8::Private::ForApi should be context-independent. (Closed)
Patch Set: Created 4 years 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
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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 500 }
501 501
502 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base, 502 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
503 Handle<String> name, Builtins::Name call, 503 Handle<String> name, Builtins::Name call,
504 bool adapt, BuiltinFunctionId id) { 504 bool adapt, BuiltinFunctionId id) {
505 Handle<JSFunction> fun = SimpleInstallGetter(base, name, call, adapt); 505 Handle<JSFunction> fun = SimpleInstallGetter(base, name, call, adapt);
506 fun->shared()->set_builtin_function_id(id); 506 fun->shared()->set_builtin_function_id(id);
507 return fun; 507 return fun;
508 } 508 }
509 509
510 void InstallConstant(Isolate* isolate, Handle<JSObject> holder,
511 const char* name, Handle<Object> value) {
512 JSObject::AddProperty(
513 holder, isolate->factory()->NewStringFromAsciiChecked(name), value,
514 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
515 }
516
510 } // namespace 517 } // namespace
511 518
512 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { 519 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
513 // Allocate the map for function instances. Maps are allocated first and their 520 // Allocate the map for function instances. Maps are allocated first and their
514 // prototypes patched later, once empty function is created. 521 // prototypes patched later, once empty function is created.
515 522
516 // Functions with this map will not have a 'prototype' property, and 523 // Functions with this map will not have a 'prototype' property, and
517 // can not be used as constructors. 524 // can not be used as constructors.
518 Handle<Map> function_without_prototype_map = 525 Handle<Map> function_without_prototype_map =
519 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); 526 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE);
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 factory->NewJSObject(isolate->object_function(), TENURED); 1624 factory->NewJSObject(isolate->object_function(), TENURED);
1618 Handle<JSFunction> symbol_fun = 1625 Handle<JSFunction> symbol_fun =
1619 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 1626 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
1620 prototype, Builtins::kSymbolConstructor); 1627 prototype, Builtins::kSymbolConstructor);
1621 symbol_fun->shared()->SetConstructStub( 1628 symbol_fun->shared()->SetConstructStub(
1622 *isolate->builtins()->SymbolConstructor_ConstructStub()); 1629 *isolate->builtins()->SymbolConstructor_ConstructStub());
1623 symbol_fun->shared()->set_length(0); 1630 symbol_fun->shared()->set_length(0);
1624 symbol_fun->shared()->DontAdaptArguments(); 1631 symbol_fun->shared()->DontAdaptArguments();
1625 native_context()->set_symbol_function(*symbol_fun); 1632 native_context()->set_symbol_function(*symbol_fun);
1626 1633
1634 // Install the Symbol.for and Symbol.keyFor functions.
1635 SimpleInstallFunction(symbol_fun, "for", Builtins::kSymbolFor, 1, false);
1636 SimpleInstallFunction(symbol_fun, "keyFor", Builtins::kSymbolKeyFor, 1,
1637 false);
1638
1639 // Install well-known symbols.
1640 InstallConstant(isolate, symbol_fun, "hasInstance",
1641 factory->has_instance_symbol());
1642 InstallConstant(isolate, symbol_fun, "isConcatSpreadable",
1643 factory->is_concat_spreadable_symbol());
1644 InstallConstant(isolate, symbol_fun, "iterator",
1645 factory->iterator_symbol());
1646 InstallConstant(isolate, symbol_fun, "match", factory->match_symbol());
1647 InstallConstant(isolate, symbol_fun, "replace", factory->replace_symbol());
1648 InstallConstant(isolate, symbol_fun, "search", factory->search_symbol());
1649 InstallConstant(isolate, symbol_fun, "species", factory->species_symbol());
1650 InstallConstant(isolate, symbol_fun, "split", factory->split_symbol());
1651 InstallConstant(isolate, symbol_fun, "toPrimitive",
1652 factory->to_primitive_symbol());
1653 InstallConstant(isolate, symbol_fun, "toStringTag",
1654 factory->to_string_tag_symbol());
1655 InstallConstant(isolate, symbol_fun, "unscopables",
1656 factory->unscopables_symbol());
1657
1627 // Install the @@toStringTag property on the {prototype}. 1658 // Install the @@toStringTag property on the {prototype}.
1628 JSObject::AddProperty( 1659 JSObject::AddProperty(
1629 prototype, factory->to_string_tag_symbol(), 1660 prototype, factory->to_string_tag_symbol(),
1630 factory->NewStringFromAsciiChecked("Symbol"), 1661 factory->NewStringFromAsciiChecked("Symbol"),
1631 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 1662 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1632 1663
1633 // Install the "constructor" property on the {prototype}. 1664 // Install the "constructor" property on the {prototype}.
1634 JSObject::AddProperty(prototype, factory->constructor_string(), symbol_fun, 1665 JSObject::AddProperty(prototype, factory->constructor_string(), symbol_fun,
1635 DONT_ENUM); 1666 DONT_ENUM);
1636 1667
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 SimpleInstallFunction(math, "sin", Builtins::kMathSin, 1, true); 2206 SimpleInstallFunction(math, "sin", Builtins::kMathSin, 1, true);
2176 SimpleInstallFunction(math, "sinh", Builtins::kMathSinh, 1, true); 2207 SimpleInstallFunction(math, "sinh", Builtins::kMathSinh, 1, true);
2177 SimpleInstallFunction(math, "sqrt", Builtins::kMathSqrt, 1, true); 2208 SimpleInstallFunction(math, "sqrt", Builtins::kMathSqrt, 1, true);
2178 SimpleInstallFunction(math, "tan", Builtins::kMathTan, 1, true); 2209 SimpleInstallFunction(math, "tan", Builtins::kMathTan, 1, true);
2179 SimpleInstallFunction(math, "tanh", Builtins::kMathTanh, 1, true); 2210 SimpleInstallFunction(math, "tanh", Builtins::kMathTanh, 1, true);
2180 SimpleInstallFunction(math, "trunc", Builtins::kMathTrunc, 1, true); 2211 SimpleInstallFunction(math, "trunc", Builtins::kMathTrunc, 1, true);
2181 2212
2182 // Install math constants. 2213 // Install math constants.
2183 double const kE = base::ieee754::exp(1.0); 2214 double const kE = base::ieee754::exp(1.0);
2184 double const kPI = 3.1415926535897932; 2215 double const kPI = 3.1415926535897932;
2185 JSObject::AddProperty( 2216 InstallConstant(isolate, math, "E", factory->NewNumber(kE));
2186 math, factory->NewStringFromAsciiChecked("E"), factory->NewNumber(kE), 2217 InstallConstant(isolate, math, "LN10",
2187 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); 2218 factory->NewNumber(base::ieee754::log(10.0)));
2188 JSObject::AddProperty( 2219 InstallConstant(isolate, math, "LN2",
2189 math, factory->NewStringFromAsciiChecked("LN10"), 2220 factory->NewNumber(base::ieee754::log(2.0)));
2190 factory->NewNumber(base::ieee754::log(10.0)), 2221 InstallConstant(isolate, math, "LOG10E",
2191 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); 2222 factory->NewNumber(base::ieee754::log10(kE)));
2192 JSObject::AddProperty( 2223 InstallConstant(isolate, math, "LOG2E",
2193 math, factory->NewStringFromAsciiChecked("LN2"), 2224 factory->NewNumber(base::ieee754::log2(kE)));
2194 factory->NewNumber(base::ieee754::log(2.0)), 2225 InstallConstant(isolate, math, "PI", factory->NewNumber(kPI));
2195 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); 2226 InstallConstant(isolate, math, "SQRT1_2",
2196 JSObject::AddProperty( 2227 factory->NewNumber(std::sqrt(0.5)));
2197 math, factory->NewStringFromAsciiChecked("LOG10E"), 2228 InstallConstant(isolate, math, "SQRT2", factory->NewNumber(std::sqrt(2.0)));
2198 factory->NewNumber(base::ieee754::log10(kE)),
2199 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
2200 JSObject::AddProperty(
2201 math, factory->NewStringFromAsciiChecked("LOG2E"),
2202 factory->NewNumber(base::ieee754::log2(kE)),
2203 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
2204 JSObject::AddProperty(
2205 math, factory->NewStringFromAsciiChecked("PI"), factory->NewNumber(kPI),
2206 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
2207 JSObject::AddProperty(
2208 math, factory->NewStringFromAsciiChecked("SQRT1_2"),
2209 factory->NewNumber(std::sqrt(0.5)),
2210 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
2211 JSObject::AddProperty(
2212 math, factory->NewStringFromAsciiChecked("SQRT2"),
2213 factory->NewNumber(std::sqrt(2.0)),
2214 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
2215 JSObject::AddProperty( 2229 JSObject::AddProperty(
2216 math, factory->to_string_tag_symbol(), 2230 math, factory->to_string_tag_symbol(),
2217 factory->NewStringFromAsciiChecked("Math"), 2231 factory->NewStringFromAsciiChecked("Math"),
2218 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 2232 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2219 } 2233 }
2220 2234
2221 { // -- A r r a y B u f f e r 2235 { // -- A r r a y B u f f e r
2222 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( 2236 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer(
2223 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, 2237 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength,
2224 BuiltinFunctionId::kArrayBufferByteLength); 2238 BuiltinFunctionId::kArrayBufferByteLength);
(...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after
4579 } 4593 }
4580 4594
4581 4595
4582 // Called when the top-level V8 mutex is destroyed. 4596 // Called when the top-level V8 mutex is destroyed.
4583 void Bootstrapper::FreeThreadResources() { 4597 void Bootstrapper::FreeThreadResources() {
4584 DCHECK(!IsActive()); 4598 DCHECK(!IsActive());
4585 } 4599 }
4586 4600
4587 } // namespace internal 4601 } // namespace internal
4588 } // namespace v8 4602 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/builtins/builtins.h » ('j') | src/heap/heap.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698