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

Side by Side Diff: Source/bindings/core/v8/V8Binding.cpp

Issue 939923002: [bindings] Break V8Binding::toDouble into fast inline and slower non-inline code paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review comments addressed. Created 5 years, 10 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 | « Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 float numberValue = toFloat(value, exceptionState); 524 float numberValue = toFloat(value, exceptionState);
525 if (exceptionState.hadException()) 525 if (exceptionState.hadException())
526 return 0; 526 return 0;
527 if (!std::isfinite(numberValue)) { 527 if (!std::isfinite(numberValue)) {
528 exceptionState.throwTypeError("The provided float value is non-finite.") ; 528 exceptionState.throwTypeError("The provided float value is non-finite.") ;
529 return 0; 529 return 0;
530 } 530 }
531 return numberValue; 531 return numberValue;
532 } 532 }
533 533
534 double toDouble(v8::Handle<v8::Value> value, ExceptionState& exceptionState) 534 double toDoubleSlow(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
535 { 535 {
536 if (value->IsNumber())
537 return value->NumberValue();
538
539 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 536 v8::Isolate* isolate = v8::Isolate::GetCurrent();
540 v8::TryCatch block(isolate); 537 v8::TryCatch block(isolate);
541 v8::Local<v8::Number> numberObject(value->ToNumber(isolate)); 538 double doubleValue = value->NumberValue();
542 if (block.HasCaught()) { 539 if (block.HasCaught()) {
543 exceptionState.rethrowV8Exception(block.Exception()); 540 exceptionState.rethrowV8Exception(block.Exception());
544 return 0; 541 return 0;
545 } 542 }
546 return numberObject->NumberValue(); 543 return doubleValue;
547 } 544 }
548 545
549 double toRestrictedDouble(v8::Handle<v8::Value> value, ExceptionState& exception State) 546 double toRestrictedDouble(v8::Handle<v8::Value> value, ExceptionState& exception State)
550 { 547 {
551 double numberValue = toDouble(value, exceptionState); 548 double numberValue = toDouble(value, exceptionState);
552 if (exceptionState.hadException()) 549 if (exceptionState.hadException())
553 return 0; 550 return 0;
554 if (!std::isfinite(numberValue)) { 551 if (!std::isfinite(numberValue)) {
555 exceptionState.throwTypeError("The provided double value is non-finite." ); 552 exceptionState.throwTypeError("The provided double value is non-finite." );
556 return 0; 553 return 0;
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 return m_resourceName; 1047 return m_resourceName;
1051 } 1048 }
1052 1049
1053 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate* isolate, ExecutionContext* context, v8::Handle<v8::Function> function) 1050 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate* isolate, ExecutionContext* context, v8::Handle<v8::Function> function)
1054 { 1051 {
1055 DevToolsFunctionInfo info(function); 1052 DevToolsFunctionInfo info(function);
1056 return InspectorFunctionCallEvent::data(context, info.scriptId(), info.resou rceName(), info.lineNumber()); 1053 return InspectorFunctionCallEvent::data(context, info.scriptId(), info.resou rceName(), info.lineNumber());
1057 } 1054 }
1058 1055
1059 } // namespace blink 1056 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698