| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/builtins.h" | 5 #include "src/builtins.h" |
| 6 | 6 |
| 7 #include "src/api-arguments.h" | 7 #include "src/api-arguments.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/base/ieee754.h" | 10 #include "src/base/ieee754.h" |
| (...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2236 HandleScope scope(isolate); | 2236 HandleScope scope(isolate); |
| 2237 JsonStringifier stringifier(isolate); | 2237 JsonStringifier stringifier(isolate); |
| 2238 Handle<Object> object = args.atOrUndefined(isolate, 1); | 2238 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 2239 Handle<Object> replacer = args.atOrUndefined(isolate, 2); | 2239 Handle<Object> replacer = args.atOrUndefined(isolate, 2); |
| 2240 Handle<Object> indent = args.atOrUndefined(isolate, 3); | 2240 Handle<Object> indent = args.atOrUndefined(isolate, 3); |
| 2241 RETURN_RESULT_OR_FAILURE(isolate, | 2241 RETURN_RESULT_OR_FAILURE(isolate, |
| 2242 stringifier.Stringify(object, replacer, indent)); | 2242 stringifier.Stringify(object, replacer, indent)); |
| 2243 } | 2243 } |
| 2244 | 2244 |
| 2245 // ----------------------------------------------------------------------------- | 2245 // ----------------------------------------------------------------------------- |
| 2246 // ES6 section 20.1 Number Objects | |
| 2247 | |
| 2248 // ES6 section 20.1.3.2 Number.prototype.toExponential ( fractionDigits ) | |
| 2249 BUILTIN(NumberPrototypeToExponential) { | |
| 2250 HandleScope scope(isolate); | |
| 2251 Handle<Object> value = args.at<Object>(0); | |
| 2252 Handle<Object> fraction_digits = args.atOrUndefined(isolate, 1); | |
| 2253 | |
| 2254 // Unwrap the receiver {value}. | |
| 2255 if (value->IsJSValue()) { | |
| 2256 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | |
| 2257 } | |
| 2258 if (!value->IsNumber()) { | |
| 2259 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2260 isolate, NewTypeError(MessageTemplate::kNotGeneric, | |
| 2261 isolate->factory()->NewStringFromAsciiChecked( | |
| 2262 "Number.prototype.toExponential"))); | |
| 2263 } | |
| 2264 double const value_number = value->Number(); | |
| 2265 | |
| 2266 // Convert the {fraction_digits} to an integer first. | |
| 2267 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 2268 isolate, fraction_digits, Object::ToInteger(isolate, fraction_digits)); | |
| 2269 double const fraction_digits_number = fraction_digits->Number(); | |
| 2270 | |
| 2271 if (std::isnan(value_number)) return isolate->heap()->nan_string(); | |
| 2272 if (std::isinf(value_number)) { | |
| 2273 return (value_number < 0.0) ? isolate->heap()->minus_infinity_string() | |
| 2274 : isolate->heap()->infinity_string(); | |
| 2275 } | |
| 2276 if (fraction_digits_number < 0.0 || fraction_digits_number > 20.0) { | |
| 2277 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2278 isolate, NewRangeError(MessageTemplate::kNumberFormatRange, | |
| 2279 isolate->factory()->NewStringFromAsciiChecked( | |
| 2280 "toExponential()"))); | |
| 2281 } | |
| 2282 int const f = args.atOrUndefined(isolate, 1)->IsUndefined(isolate) | |
| 2283 ? -1 | |
| 2284 : static_cast<int>(fraction_digits_number); | |
| 2285 char* const str = DoubleToExponentialCString(value_number, f); | |
| 2286 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | |
| 2287 DeleteArray(str); | |
| 2288 return *result; | |
| 2289 } | |
| 2290 | |
| 2291 // ES6 section 20.1.3.3 Number.prototype.toFixed ( fractionDigits ) | |
| 2292 BUILTIN(NumberPrototypeToFixed) { | |
| 2293 HandleScope scope(isolate); | |
| 2294 Handle<Object> value = args.at<Object>(0); | |
| 2295 Handle<Object> fraction_digits = args.atOrUndefined(isolate, 1); | |
| 2296 | |
| 2297 // Unwrap the receiver {value}. | |
| 2298 if (value->IsJSValue()) { | |
| 2299 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | |
| 2300 } | |
| 2301 if (!value->IsNumber()) { | |
| 2302 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2303 isolate, NewTypeError(MessageTemplate::kNotGeneric, | |
| 2304 isolate->factory()->NewStringFromAsciiChecked( | |
| 2305 "Number.prototype.toFixed"))); | |
| 2306 } | |
| 2307 double const value_number = value->Number(); | |
| 2308 | |
| 2309 // Convert the {fraction_digits} to an integer first. | |
| 2310 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 2311 isolate, fraction_digits, Object::ToInteger(isolate, fraction_digits)); | |
| 2312 double const fraction_digits_number = fraction_digits->Number(); | |
| 2313 | |
| 2314 // Check if the {fraction_digits} are in the supported range. | |
| 2315 if (fraction_digits_number < 0.0 || fraction_digits_number > 20.0) { | |
| 2316 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2317 isolate, NewRangeError(MessageTemplate::kNumberFormatRange, | |
| 2318 isolate->factory()->NewStringFromAsciiChecked( | |
| 2319 "toFixed() digits"))); | |
| 2320 } | |
| 2321 | |
| 2322 if (std::isnan(value_number)) return isolate->heap()->nan_string(); | |
| 2323 if (std::isinf(value_number)) { | |
| 2324 return (value_number < 0.0) ? isolate->heap()->minus_infinity_string() | |
| 2325 : isolate->heap()->infinity_string(); | |
| 2326 } | |
| 2327 char* const str = DoubleToFixedCString( | |
| 2328 value_number, static_cast<int>(fraction_digits_number)); | |
| 2329 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | |
| 2330 DeleteArray(str); | |
| 2331 return *result; | |
| 2332 } | |
| 2333 | |
| 2334 // ES6 section 20.1.3.5 Number.prototype.toPrecision ( precision ) | |
| 2335 BUILTIN(NumberPrototypeToPrecision) { | |
| 2336 HandleScope scope(isolate); | |
| 2337 Handle<Object> value = args.at<Object>(0); | |
| 2338 Handle<Object> precision = args.atOrUndefined(isolate, 1); | |
| 2339 | |
| 2340 // Unwrap the receiver {value}. | |
| 2341 if (value->IsJSValue()) { | |
| 2342 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | |
| 2343 } | |
| 2344 if (!value->IsNumber()) { | |
| 2345 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2346 isolate, NewTypeError(MessageTemplate::kNotGeneric, | |
| 2347 isolate->factory()->NewStringFromAsciiChecked( | |
| 2348 "Number.prototype.toPrecision"))); | |
| 2349 } | |
| 2350 double const value_number = value->Number(); | |
| 2351 | |
| 2352 // If no {precision} was specified, just return ToString of {value}. | |
| 2353 if (precision->IsUndefined(isolate)) { | |
| 2354 return *isolate->factory()->NumberToString(value); | |
| 2355 } | |
| 2356 | |
| 2357 // Convert the {precision} to an integer first. | |
| 2358 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, precision, | |
| 2359 Object::ToInteger(isolate, precision)); | |
| 2360 double const precision_number = precision->Number(); | |
| 2361 | |
| 2362 if (std::isnan(value_number)) return isolate->heap()->nan_string(); | |
| 2363 if (std::isinf(value_number)) { | |
| 2364 return (value_number < 0.0) ? isolate->heap()->minus_infinity_string() | |
| 2365 : isolate->heap()->infinity_string(); | |
| 2366 } | |
| 2367 if (precision_number < 1.0 || precision_number > 21.0) { | |
| 2368 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2369 isolate, NewRangeError(MessageTemplate::kToPrecisionFormatRange)); | |
| 2370 } | |
| 2371 char* const str = DoubleToPrecisionCString( | |
| 2372 value_number, static_cast<int>(precision_number)); | |
| 2373 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | |
| 2374 DeleteArray(str); | |
| 2375 return *result; | |
| 2376 } | |
| 2377 | |
| 2378 // ES6 section 20.1.3.6 Number.prototype.toString ( [ radix ] ) | |
| 2379 BUILTIN(NumberPrototypeToString) { | |
| 2380 HandleScope scope(isolate); | |
| 2381 Handle<Object> value = args.at<Object>(0); | |
| 2382 Handle<Object> radix = args.atOrUndefined(isolate, 1); | |
| 2383 | |
| 2384 // Unwrap the receiver {value}. | |
| 2385 if (value->IsJSValue()) { | |
| 2386 value = handle(Handle<JSValue>::cast(value)->value(), isolate); | |
| 2387 } | |
| 2388 if (!value->IsNumber()) { | |
| 2389 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2390 isolate, NewTypeError(MessageTemplate::kNotGeneric, | |
| 2391 isolate->factory()->NewStringFromAsciiChecked( | |
| 2392 "Number.prototype.toString"))); | |
| 2393 } | |
| 2394 double const value_number = value->Number(); | |
| 2395 | |
| 2396 // If no {radix} was specified, just return ToString of {value}. | |
| 2397 if (radix->IsUndefined(isolate)) { | |
| 2398 return *isolate->factory()->NumberToString(value); | |
| 2399 } | |
| 2400 | |
| 2401 // Convert the {radix} to an integer first. | |
| 2402 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, radix, | |
| 2403 Object::ToInteger(isolate, radix)); | |
| 2404 double const radix_number = radix->Number(); | |
| 2405 | |
| 2406 // If {radix} is 10, just return ToString of {value}. | |
| 2407 if (radix_number == 10.0) return *isolate->factory()->NumberToString(value); | |
| 2408 | |
| 2409 // Make sure the {radix} is within the valid range. | |
| 2410 if (radix_number < 2.0 || radix_number > 36.0) { | |
| 2411 THROW_NEW_ERROR_RETURN_FAILURE( | |
| 2412 isolate, NewRangeError(MessageTemplate::kToRadixFormatRange)); | |
| 2413 } | |
| 2414 | |
| 2415 // Fast case where the result is a one character string. | |
| 2416 if (IsUint32Double(value_number) && value_number < radix_number) { | |
| 2417 // Character array used for conversion. | |
| 2418 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; | |
| 2419 return *isolate->factory()->LookupSingleCharacterStringFromCode( | |
| 2420 kCharTable[static_cast<uint32_t>(value_number)]); | |
| 2421 } | |
| 2422 | |
| 2423 // Slow case. | |
| 2424 if (std::isnan(value_number)) return isolate->heap()->nan_string(); | |
| 2425 if (std::isinf(value_number)) { | |
| 2426 return (value_number < 0.0) ? isolate->heap()->minus_infinity_string() | |
| 2427 : isolate->heap()->infinity_string(); | |
| 2428 } | |
| 2429 char* const str = | |
| 2430 DoubleToRadixCString(value_number, static_cast<int>(radix_number)); | |
| 2431 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | |
| 2432 DeleteArray(str); | |
| 2433 return *result; | |
| 2434 } | |
| 2435 | |
| 2436 // ES6 section 20.1.3.7 Number.prototype.valueOf ( ) | |
| 2437 void Builtins::Generate_NumberPrototypeValueOf(CodeStubAssembler* assembler) { | |
| 2438 typedef compiler::Node Node; | |
| 2439 | |
| 2440 Node* receiver = assembler->Parameter(0); | |
| 2441 Node* context = assembler->Parameter(3); | |
| 2442 | |
| 2443 Node* result = assembler->ToThisValue( | |
| 2444 context, receiver, PrimitiveType::kNumber, "Number.prototype.valueOf"); | |
| 2445 assembler->Return(result); | |
| 2446 } | |
| 2447 | |
| 2448 // ----------------------------------------------------------------------------- | |
| 2449 // ES6 section 20.2.2 Function Properties of the Math Object | 2246 // ES6 section 20.2.2 Function Properties of the Math Object |
| 2450 | 2247 |
| 2451 // ES6 section - 20.2.2.1 Math.abs ( x ) | 2248 // ES6 section - 20.2.2.1 Math.abs ( x ) |
| 2452 void Builtins::Generate_MathAbs(CodeStubAssembler* assembler) { | 2249 void Builtins::Generate_MathAbs(CodeStubAssembler* assembler) { |
| 2453 using compiler::Node; | 2250 using compiler::Node; |
| 2454 Node* x = assembler->Parameter(1); | 2251 Node* x = assembler->Parameter(1); |
| 2455 Node* context = assembler->Parameter(4); | 2252 Node* context = assembler->Parameter(4); |
| 2456 Node* x_value = assembler->TruncateTaggedToFloat64(context, x); | 2253 Node* x_value = assembler->TruncateTaggedToFloat64(context, x); |
| 2457 Node* value = assembler->Float64Abs(x_value); | 2254 Node* value = assembler->Float64Abs(x_value); |
| 2458 Node* result = assembler->ChangeFloat64ToTagged(value); | 2255 Node* result = assembler->ChangeFloat64ToTagged(value); |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3397 Handle<JSObject> result; | 3194 Handle<JSObject> result; |
| 3398 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 3195 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 3399 JSObject::New(target, new_target)); | 3196 JSObject::New(target, new_target)); |
| 3400 Handle<JSValue>::cast(result)->set_value( | 3197 Handle<JSValue>::cast(result)->set_value( |
| 3401 isolate->heap()->ToBoolean(value->BooleanValue())); | 3198 isolate->heap()->ToBoolean(value->BooleanValue())); |
| 3402 return *result; | 3199 return *result; |
| 3403 } | 3200 } |
| 3404 | 3201 |
| 3405 | 3202 |
| 3406 // ES6 section 19.3.3.2 Boolean.prototype.toString ( ) | 3203 // ES6 section 19.3.3.2 Boolean.prototype.toString ( ) |
| 3407 void Builtins::Generate_BooleanPrototypeToString(CodeStubAssembler* assembler) { | 3204 BUILTIN(BooleanPrototypeToString) { |
| 3408 typedef compiler::Node Node; | 3205 HandleScope scope(isolate); |
| 3409 | 3206 Handle<Object> receiver = args.receiver(); |
| 3410 Node* receiver = assembler->Parameter(0); | 3207 if (receiver->IsJSValue()) { |
| 3411 Node* context = assembler->Parameter(3); | 3208 receiver = handle(Handle<JSValue>::cast(receiver)->value(), isolate); |
| 3412 | 3209 } |
| 3413 Node* value = assembler->ToThisValue( | 3210 if (!receiver->IsBoolean()) { |
| 3414 context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.toString"); | 3211 THROW_NEW_ERROR_RETURN_FAILURE( |
| 3415 Node* result = assembler->LoadObjectField(value, Oddball::kToStringOffset); | 3212 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
| 3416 assembler->Return(result); | 3213 isolate->factory()->NewStringFromAsciiChecked( |
| 3214 "Boolean.prototype.toString"))); |
| 3215 } |
| 3216 return Handle<Oddball>::cast(receiver)->to_string(); |
| 3417 } | 3217 } |
| 3418 | 3218 |
| 3219 |
| 3419 // ES6 section 19.3.3.3 Boolean.prototype.valueOf ( ) | 3220 // ES6 section 19.3.3.3 Boolean.prototype.valueOf ( ) |
| 3420 void Builtins::Generate_BooleanPrototypeValueOf(CodeStubAssembler* assembler) { | 3221 BUILTIN(BooleanPrototypeValueOf) { |
| 3421 typedef compiler::Node Node; | 3222 HandleScope scope(isolate); |
| 3223 Handle<Object> receiver = args.receiver(); |
| 3224 if (receiver->IsJSValue()) { |
| 3225 receiver = handle(Handle<JSValue>::cast(receiver)->value(), isolate); |
| 3226 } |
| 3227 if (!receiver->IsBoolean()) { |
| 3228 THROW_NEW_ERROR_RETURN_FAILURE( |
| 3229 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
| 3230 isolate->factory()->NewStringFromAsciiChecked( |
| 3231 "Boolean.prototype.valueOf"))); |
| 3232 } |
| 3233 return *receiver; |
| 3234 } |
| 3422 | 3235 |
| 3423 Node* receiver = assembler->Parameter(0); | |
| 3424 Node* context = assembler->Parameter(3); | |
| 3425 | |
| 3426 Node* result = assembler->ToThisValue( | |
| 3427 context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.valueOf"); | |
| 3428 assembler->Return(result); | |
| 3429 } | |
| 3430 | 3236 |
| 3431 // ----------------------------------------------------------------------------- | 3237 // ----------------------------------------------------------------------------- |
| 3432 // ES6 section 24.2 DataView Objects | 3238 // ES6 section 24.2 DataView Objects |
| 3433 | 3239 |
| 3434 | 3240 |
| 3435 // ES6 section 24.2.2 The DataView Constructor for the [[Call]] case. | 3241 // ES6 section 24.2.2 The DataView Constructor for the [[Call]] case. |
| 3436 BUILTIN(DataViewConstructor) { | 3242 BUILTIN(DataViewConstructor) { |
| 3437 HandleScope scope(isolate); | 3243 HandleScope scope(isolate); |
| 3438 THROW_NEW_ERROR_RETURN_FAILURE( | 3244 THROW_NEW_ERROR_RETURN_FAILURE( |
| 3439 isolate, | 3245 isolate, |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4956 | 4762 |
| 4957 // Do not lazily compute eval position for AsyncFunction, as they may not be | 4763 // Do not lazily compute eval position for AsyncFunction, as they may not be |
| 4958 // determined after the function is resumed. | 4764 // determined after the function is resumed. |
| 4959 Handle<Script> script = handle(Script::cast(func->shared()->script())); | 4765 Handle<Script> script = handle(Script::cast(func->shared()->script())); |
| 4960 int position = script->GetEvalPosition(); | 4766 int position = script->GetEvalPosition(); |
| 4961 USE(position); | 4767 USE(position); |
| 4962 | 4768 |
| 4963 return *func; | 4769 return *func; |
| 4964 } | 4770 } |
| 4965 | 4771 |
| 4966 // ES6 19.1.3.6 Object.prototype.toString | |
| 4967 BUILTIN(ObjectProtoToString) { | |
| 4968 HandleScope scope(isolate); | |
| 4969 Handle<Object> object = args.at<Object>(0); | |
| 4970 RETURN_RESULT_OR_FAILURE(isolate, | |
| 4971 Object::ObjectProtoToString(isolate, object)); | |
| 4972 } | |
| 4973 | |
| 4974 // ----------------------------------------------------------------------------- | |
| 4975 // ES6 section 19.4 Symbol Objects | |
| 4976 | |
| 4977 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case. | 4772 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case. |
| 4978 BUILTIN(SymbolConstructor) { | 4773 BUILTIN(SymbolConstructor) { |
| 4979 HandleScope scope(isolate); | 4774 HandleScope scope(isolate); |
| 4980 Handle<Symbol> result = isolate->factory()->NewSymbol(); | 4775 Handle<Symbol> result = isolate->factory()->NewSymbol(); |
| 4981 Handle<Object> description = args.atOrUndefined(isolate, 1); | 4776 Handle<Object> description = args.atOrUndefined(isolate, 1); |
| 4982 if (!description->IsUndefined(isolate)) { | 4777 if (!description->IsUndefined(isolate)) { |
| 4983 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description, | 4778 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description, |
| 4984 Object::ToString(isolate, description)); | 4779 Object::ToString(isolate, description)); |
| 4985 result->set_name(*description); | 4780 result->set_name(*description); |
| 4986 } | 4781 } |
| 4987 return *result; | 4782 return *result; |
| 4988 } | 4783 } |
| 4989 | 4784 |
| 4990 | 4785 |
| 4991 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case. | 4786 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case. |
| 4992 BUILTIN(SymbolConstructor_ConstructStub) { | 4787 BUILTIN(SymbolConstructor_ConstructStub) { |
| 4993 HandleScope scope(isolate); | 4788 HandleScope scope(isolate); |
| 4994 THROW_NEW_ERROR_RETURN_FAILURE( | 4789 THROW_NEW_ERROR_RETURN_FAILURE( |
| 4995 isolate, NewTypeError(MessageTemplate::kNotConstructor, | 4790 isolate, NewTypeError(MessageTemplate::kNotConstructor, |
| 4996 isolate->factory()->Symbol_string())); | 4791 isolate->factory()->Symbol_string())); |
| 4997 } | 4792 } |
| 4998 | 4793 |
| 4999 // ES6 section 19.4.3.4 Symbol.prototype [ @@toPrimitive ] ( hint ) | |
| 5000 void Builtins::Generate_SymbolPrototypeToPrimitive( | |
| 5001 CodeStubAssembler* assembler) { | |
| 5002 typedef compiler::Node Node; | |
| 5003 | 4794 |
| 5004 Node* receiver = assembler->Parameter(0); | 4795 // ES6 19.1.3.6 Object.prototype.toString |
| 5005 Node* context = assembler->Parameter(4); | 4796 BUILTIN(ObjectProtoToString) { |
| 5006 | 4797 HandleScope scope(isolate); |
| 5007 Node* result = | 4798 Handle<Object> object = args.at<Object>(0); |
| 5008 assembler->ToThisValue(context, receiver, PrimitiveType::kSymbol, | 4799 RETURN_RESULT_OR_FAILURE(isolate, |
| 5009 "Symbol.prototype [ @@toPrimitive ]"); | 4800 Object::ObjectProtoToString(isolate, object)); |
| 5010 assembler->Return(result); | |
| 5011 } | |
| 5012 | |
| 5013 // ES6 section 19.4.3.2 Symbol.prototype.toString ( ) | |
| 5014 void Builtins::Generate_SymbolPrototypeToString(CodeStubAssembler* assembler) { | |
| 5015 typedef compiler::Node Node; | |
| 5016 | |
| 5017 Node* receiver = assembler->Parameter(0); | |
| 5018 Node* context = assembler->Parameter(3); | |
| 5019 | |
| 5020 Node* value = assembler->ToThisValue( | |
| 5021 context, receiver, PrimitiveType::kSymbol, "Symbol.prototype.toString"); | |
| 5022 Node* result = | |
| 5023 assembler->CallRuntime(Runtime::kSymbolDescriptiveString, context, value); | |
| 5024 assembler->Return(result); | |
| 5025 } | |
| 5026 | |
| 5027 // ES6 section 19.4.3.3 Symbol.prototype.valueOf ( ) | |
| 5028 void Builtins::Generate_SymbolPrototypeValueOf(CodeStubAssembler* assembler) { | |
| 5029 typedef compiler::Node Node; | |
| 5030 | |
| 5031 Node* receiver = assembler->Parameter(0); | |
| 5032 Node* context = assembler->Parameter(3); | |
| 5033 | |
| 5034 Node* result = assembler->ToThisValue( | |
| 5035 context, receiver, PrimitiveType::kSymbol, "Symbol.prototype.valueOf"); | |
| 5036 assembler->Return(result); | |
| 5037 } | 4801 } |
| 5038 | 4802 |
| 5039 // ----------------------------------------------------------------------------- | 4803 // ----------------------------------------------------------------------------- |
| 5040 // ES6 section 21.1 String Objects | 4804 // ES6 section 21.1 String Objects |
| 5041 | 4805 |
| 5042 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) | 4806 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) |
| 5043 void Builtins::Generate_StringFromCharCode(CodeStubAssembler* assembler) { | 4807 void Builtins::Generate_StringFromCharCode(CodeStubAssembler* assembler) { |
| 5044 typedef CodeStubAssembler::Label Label; | 4808 typedef CodeStubAssembler::Label Label; |
| 5045 typedef compiler::Node Node; | 4809 typedef compiler::Node Node; |
| 5046 typedef CodeStubAssembler::Variable Variable; | 4810 typedef CodeStubAssembler::Variable Variable; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5499 assembler->Return(assembler->NaNConstant()); | 5263 assembler->Return(assembler->NaNConstant()); |
| 5500 assembler->Bind(&if_positioninbounds); | 5264 assembler->Bind(&if_positioninbounds); |
| 5501 } | 5265 } |
| 5502 | 5266 |
| 5503 // Load the character at the {position} from the {receiver}. | 5267 // Load the character at the {position} from the {receiver}. |
| 5504 Node* value = assembler->StringCharCodeAt(receiver, position); | 5268 Node* value = assembler->StringCharCodeAt(receiver, position); |
| 5505 Node* result = assembler->SmiFromWord32(value); | 5269 Node* result = assembler->SmiFromWord32(value); |
| 5506 assembler->Return(result); | 5270 assembler->Return(result); |
| 5507 } | 5271 } |
| 5508 | 5272 |
| 5509 // ES6 section 21.1.3.25 String.prototype.toString () | 5273 // ES6 section 21.1.3.25 String.prototype.trim () |
| 5510 void Builtins::Generate_StringPrototypeToString(CodeStubAssembler* assembler) { | |
| 5511 typedef compiler::Node Node; | |
| 5512 | |
| 5513 Node* receiver = assembler->Parameter(0); | |
| 5514 Node* context = assembler->Parameter(3); | |
| 5515 | |
| 5516 Node* result = assembler->ToThisValue( | |
| 5517 context, receiver, PrimitiveType::kString, "String.prototype.toString"); | |
| 5518 assembler->Return(result); | |
| 5519 } | |
| 5520 | |
| 5521 // ES6 section 21.1.3.27 String.prototype.trim () | |
| 5522 BUILTIN(StringPrototypeTrim) { | 5274 BUILTIN(StringPrototypeTrim) { |
| 5523 HandleScope scope(isolate); | 5275 HandleScope scope(isolate); |
| 5524 TO_THIS_STRING(string, "String.prototype.trim"); | 5276 TO_THIS_STRING(string, "String.prototype.trim"); |
| 5525 return *String::Trim(string, String::kTrim); | 5277 return *String::Trim(string, String::kTrim); |
| 5526 } | 5278 } |
| 5527 | 5279 |
| 5528 // Non-standard WebKit extension | 5280 // Non-standard WebKit extension |
| 5529 BUILTIN(StringPrototypeTrimLeft) { | 5281 BUILTIN(StringPrototypeTrimLeft) { |
| 5530 HandleScope scope(isolate); | 5282 HandleScope scope(isolate); |
| 5531 TO_THIS_STRING(string, "String.prototype.trimLeft"); | 5283 TO_THIS_STRING(string, "String.prototype.trimLeft"); |
| 5532 return *String::Trim(string, String::kTrimLeft); | 5284 return *String::Trim(string, String::kTrimLeft); |
| 5533 } | 5285 } |
| 5534 | 5286 |
| 5535 // Non-standard WebKit extension | 5287 // Non-standard WebKit extension |
| 5536 BUILTIN(StringPrototypeTrimRight) { | 5288 BUILTIN(StringPrototypeTrimRight) { |
| 5537 HandleScope scope(isolate); | 5289 HandleScope scope(isolate); |
| 5538 TO_THIS_STRING(string, "String.prototype.trimRight"); | 5290 TO_THIS_STRING(string, "String.prototype.trimRight"); |
| 5539 return *String::Trim(string, String::kTrimRight); | 5291 return *String::Trim(string, String::kTrimRight); |
| 5540 } | 5292 } |
| 5541 | 5293 |
| 5542 // ES6 section 21.1.3.28 String.prototype.valueOf ( ) | |
| 5543 void Builtins::Generate_StringPrototypeValueOf(CodeStubAssembler* assembler) { | |
| 5544 typedef compiler::Node Node; | |
| 5545 | |
| 5546 Node* receiver = assembler->Parameter(0); | |
| 5547 Node* context = assembler->Parameter(3); | |
| 5548 | |
| 5549 Node* result = assembler->ToThisValue( | |
| 5550 context, receiver, PrimitiveType::kString, "String.prototype.valueOf"); | |
| 5551 assembler->Return(result); | |
| 5552 } | |
| 5553 | |
| 5554 // ----------------------------------------------------------------------------- | 5294 // ----------------------------------------------------------------------------- |
| 5555 // ES6 section 21.1 ArrayBuffer Objects | 5295 // ES6 section 21.1 ArrayBuffer Objects |
| 5556 | 5296 |
| 5557 // ES6 section 24.1.2.1 ArrayBuffer ( length ) for the [[Call]] case. | 5297 // ES6 section 24.1.2.1 ArrayBuffer ( length ) for the [[Call]] case. |
| 5558 BUILTIN(ArrayBufferConstructor) { | 5298 BUILTIN(ArrayBufferConstructor) { |
| 5559 HandleScope scope(isolate); | 5299 HandleScope scope(isolate); |
| 5560 Handle<JSFunction> target = args.target<JSFunction>(); | 5300 Handle<JSFunction> target = args.target<JSFunction>(); |
| 5561 DCHECK(*target == target->native_context()->array_buffer_fun() || | 5301 DCHECK(*target == target->native_context()->array_buffer_fun() || |
| 5562 *target == target->native_context()->shared_array_buffer_fun()); | 5302 *target == target->native_context()->shared_array_buffer_fun()); |
| 5563 THROW_NEW_ERROR_RETURN_FAILURE( | 5303 THROW_NEW_ERROR_RETURN_FAILURE( |
| (...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6686 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 6426 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 6687 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 6427 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 6688 #undef DEFINE_BUILTIN_ACCESSOR_C | 6428 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 6689 #undef DEFINE_BUILTIN_ACCESSOR_A | 6429 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 6690 #undef DEFINE_BUILTIN_ACCESSOR_T | 6430 #undef DEFINE_BUILTIN_ACCESSOR_T |
| 6691 #undef DEFINE_BUILTIN_ACCESSOR_S | 6431 #undef DEFINE_BUILTIN_ACCESSOR_S |
| 6692 #undef DEFINE_BUILTIN_ACCESSOR_H | 6432 #undef DEFINE_BUILTIN_ACCESSOR_H |
| 6693 | 6433 |
| 6694 } // namespace internal | 6434 } // namespace internal |
| 6695 } // namespace v8 | 6435 } // namespace v8 |
| OLD | NEW |