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

Side by Side Diff: src/bootstrapper.cc

Issue 2586763002: [intl] Create the Intl constructors to C++ (Closed)
Patch Set: Fix factory references 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
« no previous file with comments | « no previous file | src/js/i18n.js » ('j') | test/intl/toStringTag.js » ('J')
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 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 InstallConstant(isolate, math, "PI", factory->NewNumber(kPI)); 2317 InstallConstant(isolate, math, "PI", factory->NewNumber(kPI));
2318 InstallConstant(isolate, math, "SQRT1_2", 2318 InstallConstant(isolate, math, "SQRT1_2",
2319 factory->NewNumber(std::sqrt(0.5))); 2319 factory->NewNumber(std::sqrt(0.5)));
2320 InstallConstant(isolate, math, "SQRT2", factory->NewNumber(std::sqrt(2.0))); 2320 InstallConstant(isolate, math, "SQRT2", factory->NewNumber(std::sqrt(2.0)));
2321 JSObject::AddProperty( 2321 JSObject::AddProperty(
2322 math, factory->to_string_tag_symbol(), 2322 math, factory->to_string_tag_symbol(),
2323 factory->NewStringFromAsciiChecked("Math"), 2323 factory->NewStringFromAsciiChecked("Math"),
2324 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); 2324 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2325 } 2325 }
2326 2326
2327 #ifdef V8_I18N_SUPPORT
2328 { // -- I n t l
2329 Handle<String> name = factory->InternalizeUtf8String("Intl");
2330 Handle<JSFunction> cons = factory->NewFunction(name);
2331 JSFunction::SetInstancePrototype(
2332 cons,
2333 Handle<Object>(native_context()->initial_object_prototype(), isolate));
2334 Handle<JSObject> intl = factory->NewJSObject(cons, TENURED);
2335 DCHECK(intl->IsJSObject());
2336 JSObject::AddProperty(global, name, intl, DONT_ENUM);
2337
2338 Handle<JSObject> date_time_format_prototype =
2339 factory->NewJSObject(isolate->object_function(), TENURED);
2340 // Install the @@toStringTag property on the {prototype}.
2341 JSObject::AddProperty(
2342 date_time_format_prototype, factory->to_string_tag_symbol(),
2343 factory->Object_string(),
2344 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2345 Handle<JSFunction> date_time_format_constructor = InstallFunction(
2346 intl, "DateTimeFormat", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2347 date_time_format_prototype, Builtins::kIllegal);
2348 JSObject::AddProperty(date_time_format_prototype,
2349 factory->constructor_string(),
2350 date_time_format_constructor, DONT_ENUM);
2351
2352 Handle<JSObject> number_format_prototype =
2353 factory->NewJSObject(isolate->object_function(), TENURED);
2354 // Install the @@toStringTag property on the {prototype}.
2355 JSObject::AddProperty(
2356 number_format_prototype, factory->to_string_tag_symbol(),
2357 factory->Object_string(),
2358 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2359 Handle<JSFunction> number_format_constructor = InstallFunction(
2360 intl, "NumberFormat", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2361 number_format_prototype, Builtins::kIllegal);
Yang 2016/12/21 13:23:13 What's the point of installing half the function h
Dan Ehrenberg 2016/12/21 13:41:35 In a follow-on patch, i'll change the allocated ob
2362 JSObject::AddProperty(number_format_prototype,
2363 factory->constructor_string(),
2364 number_format_constructor, DONT_ENUM);
2365
2366 Handle<JSObject> collator_prototype =
2367 factory->NewJSObject(isolate->object_function(), TENURED);
2368 // Install the @@toStringTag property on the {prototype}.
2369 JSObject::AddProperty(
2370 collator_prototype, factory->to_string_tag_symbol(),
2371 factory->Object_string(),
2372 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2373 Handle<JSFunction> collator_constructor =
2374 InstallFunction(intl, "Collator", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2375 collator_prototype, Builtins::kIllegal);
2376 JSObject::AddProperty(collator_prototype, factory->constructor_string(),
2377 collator_constructor, DONT_ENUM);
2378
2379 Handle<JSObject> v8_break_iterator_prototype =
2380 factory->NewJSObject(isolate->object_function(), TENURED);
2381 // Install the @@toStringTag property on the {prototype}.
2382 JSObject::AddProperty(
2383 v8_break_iterator_prototype, factory->to_string_tag_symbol(),
2384 factory->Object_string(),
2385 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
2386 Handle<JSFunction> v8_break_iterator_constructor = InstallFunction(
2387 intl, "v8BreakIterator", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2388 v8_break_iterator_prototype, Builtins::kIllegal);
2389 JSObject::AddProperty(v8_break_iterator_prototype,
2390 factory->constructor_string(),
2391 v8_break_iterator_constructor, DONT_ENUM);
2392 }
2393 #endif // V8_I18N_SUPPORT
2394
2327 { // -- A r r a y B u f f e r 2395 { // -- A r r a y B u f f e r
2328 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer( 2396 Handle<JSFunction> array_buffer_fun = InstallArrayBuffer(
2329 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength, 2397 global, "ArrayBuffer", Builtins::kArrayBufferPrototypeGetByteLength,
2330 BuiltinFunctionId::kArrayBufferByteLength); 2398 BuiltinFunctionId::kArrayBufferByteLength);
2331 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, 2399 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun,
2332 Context::ARRAY_BUFFER_FUN_INDEX); 2400 Context::ARRAY_BUFFER_FUN_INDEX);
2333 } 2401 }
2334 2402
2335 { // -- T y p e d A r r a y 2403 { // -- T y p e d A r r a y
2336 Handle<JSObject> prototype = 2404 Handle<JSObject> prototype =
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
4656 } 4724 }
4657 4725
4658 4726
4659 // Called when the top-level V8 mutex is destroyed. 4727 // Called when the top-level V8 mutex is destroyed.
4660 void Bootstrapper::FreeThreadResources() { 4728 void Bootstrapper::FreeThreadResources() {
4661 DCHECK(!IsActive()); 4729 DCHECK(!IsActive());
4662 } 4730 }
4663 4731
4664 } // namespace internal 4732 } // namespace internal
4665 } // namespace v8 4733 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/js/i18n.js » ('j') | test/intl/toStringTag.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698